aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorManolo Carrasco <manolo@apache.org>2012-06-21 12:18:46 +0000
committerManolo Carrasco <manolo@apache.org>2012-06-21 12:18:46 +0000
commit9144d84ba56a120dba475205873e9d33e796bf95 (patch)
tree3e0b3883a51efed8eb6d07dfe2f7b9da225b8246
parentb55a024ad1629d2db2b1cda04b8d585862c9c07b (diff)
downloadgwtquery-9144d84ba56a120dba475205873e9d33e796bf95.tar.gz
gwtquery-9144d84ba56a120dba475205873e9d33e796bf95.zip
fixe live() so as it behaves the same than jquery
-rw-r--r--gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/events/EventsListener.java16
1 files changed, 8 insertions, 8 deletions
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/events/EventsListener.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/events/EventsListener.java
index 5221b634..5d56359e 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/events/EventsListener.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/events/EventsListener.java
@@ -173,9 +173,8 @@ public class EventsListener implements EventListener {
return true;
}
- boolean result = true;
+ Element stopElement = null;
GqEvent gqEvent = GqEvent.create(event);
- outerLoop:
for (String cssSelector : realCurrentTargetBySelector.keys()) {
JsObjectArray<BindFunction> bindFunctions = bindFunctionBySelector.get(cssSelector);
for (int i = 0; bindFunctions != null && i < bindFunctions.length(); i++) {
@@ -184,11 +183,12 @@ public class EventsListener implements EventListener {
NodeList<Element> n = realCurrentTargetBySelector.get(cssSelector);
for (int j = 0; n != null && j < n.getLength(); j++) {
Element element = n.getItem(i);
- gqEvent.setCurrentElementTarget(element);
- result = f.fire(gqEvent);
- if (!result) {
- // Event should not continue because returning false, means to run it once
- break outerLoop;
+ // When an event fired in an element stops bubbling we have to fire also all other
+ // handlers for this element bound to this element
+ if (stopElement == null || element.equals(stopElement)) {
+ if (!f.fire(gqEvent)) {
+ stopElement = element;
+ }
}
}
}
@@ -197,7 +197,7 @@ public class EventsListener implements EventListener {
// trick to reset the right currentTarget on the original event on ie
gqEvent.setCurrentElementTarget(liveContextElement);
- return result;
+ return stopElement == null;
}
/**