You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by jk...@apache.org on 2015/10/23 12:27:27 UTC
[2/2] tapestry-5 git commit: TAP5-2397: use a separate event to
initialize components in newly inserted DOM content
TAP5-2397: use a separate event to initialize components in newly inserted DOM content
Project: http://git-wip-us.apache.org/repos/asf/tapestry-5/repo
Commit: http://git-wip-us.apache.org/repos/asf/tapestry-5/commit/a42b2501
Tree: http://git-wip-us.apache.org/repos/asf/tapestry-5/tree/a42b2501
Diff: http://git-wip-us.apache.org/repos/asf/tapestry-5/diff/a42b2501
Branch: refs/heads/master
Commit: a42b250166acded71ee6792f1b28fbfc973c7a70
Parents: 9393164
Author: Jochen Kemnade <jo...@eddyson.de>
Authored: Fri Oct 23 11:55:25 2015 +0200
Committer: Jochen Kemnade <jo...@eddyson.de>
Committed: Fri Oct 23 12:14:53 2015 +0200
----------------------------------------------------------------------
.../modules/t5/core/ajaxformloop.coffee | 4 +++
.../META-INF/modules/t5/core/events.coffee | 2 ++
.../META-INF/modules/t5/core/zone.coffee | 1 +
.../org/apache/tapestry5/t5-core-dom.coffee | 2 +-
.../tapestry5/integration/app1/AjaxTests.java | 27 ++++++++++++++++++++
5 files changed, 35 insertions(+), 1 deletion(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a42b2501/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/ajaxformloop.coffee
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/ajaxformloop.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/ajaxformloop.coffee
index ef1884e..d98a791 100644
--- a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/ajaxformloop.coffee
+++ b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/ajaxformloop.coffee
@@ -72,9 +72,13 @@ define ["./dom", "./events", "./console", "./ajax"],
insertionPoint.insertBefore newElement
+ # Initialize components inside the new row
+ newElement.trigger events.initializeComponents
+
# Trigger this event, to inform the world that the zone-like new element has been updated
# with content.
insertionPoint.trigger events.zone.didUpdate
+
return
return false
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a42b2501/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/events.coffee
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/events.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/events.coffee
index 02187fd..ec7da0b 100644
--- a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/events.coffee
+++ b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/events.coffee
@@ -183,3 +183,5 @@ define
# boolean. The fragment will show or hide itself if necessary (triggering the `element.didShow` or
# `element.didHide` event).
changeVisibility: "t5:fragment:change-visibility"
+ # Event to scan inserted DOM content for components to initialize (see t5/core/dom:scanner)
+ initializeComponents : "t5:initializeComponents"
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a42b2501/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/zone.coffee
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/zone.coffee b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/zone.coffee
index ae1f9be..d5f9974 100644
--- a/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/zone.coffee
+++ b/tapestry-core/src/main/coffeescript/META-INF/modules/t5/core/zone.coffee
@@ -102,6 +102,7 @@ define ["./dom", "./events", "./ajax", "./console", "./forms", "underscore"],
unless content is undefined
@update content
+ @trigger events.initializeComponents
@trigger events.zone.didUpdate
dom.onDocument events.zone.refresh, (event) ->
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a42b2501/tapestry-core/src/main/preprocessed-coffeescript/org/apache/tapestry5/t5-core-dom.coffee
----------------------------------------------------------------------
diff --git a/tapestry-core/src/main/preprocessed-coffeescript/org/apache/tapestry5/t5-core-dom.coffee b/tapestry-core/src/main/preprocessed-coffeescript/org/apache/tapestry5/t5-core-dom.coffee
index e225974..9d419bc 100644
--- a/tapestry-core/src/main/preprocessed-coffeescript/org/apache/tapestry5/t5-core-dom.coffee
+++ b/tapestry-core/src/main/preprocessed-coffeescript/org/apache/tapestry5/t5-core-dom.coffee
@@ -813,7 +813,7 @@ define ["underscore", "./utils", "./events", "jquery"],
if scanners is null
scanners = []
- exports.body.on events.zone.didUpdate, ->
+ exports.body.on events.initializeComponents, ->
f this for f in scanners
return
http://git-wip-us.apache.org/repos/asf/tapestry-5/blob/a42b2501/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/AjaxTests.java
----------------------------------------------------------------------
diff --git a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/AjaxTests.java b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/AjaxTests.java
index 830ad92..665570b 100644
--- a/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/AjaxTests.java
+++ b/tapestry-core/src/test/java/org/apache/tapestry5/integration/app1/AjaxTests.java
@@ -284,4 +284,31 @@ public class AjaxTests extends App1TestCase
assertText("message", "Redirected from XHR");
}
+
+ /**
+ * TAP5-2397
+ */
+ @Test
+ public void add_datefield_in_ajaxformloop()
+ {
+ openLinks("DateField inside AjaxFormLoop");
+
+ click("link=Add row");
+
+ waitForAjaxRequestsToComplete();
+
+ // now the datefield module is loaded and dom.scanner has been invoked
+ // the second insertion is problematic
+
+ click("css=.glyphicon-minus-sign");
+
+ click("link=Add row");
+
+ waitForAjaxRequestsToComplete();
+
+ click("css=.glyphicon-calendar");
+
+ assertTextPresent("Today");
+
+ }
}