live(int eventbits, Object data, Function...funcs);
/**
*
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Events.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Events.java
index fc58ce0f..bdd3802e 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Events.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/Events.java
@@ -109,21 +109,33 @@ public class Events extends GQuery {
public GQuery die(String eventName) {
EventsListener.getInstance(
Element.is(currentContext) ? (Element) currentContext : body).die(
- eventName, currentSelector);
+ eventName, currentSelector);
return this;
}
- public GQuery live(String eventName, final Object data, Function func) {
+ public GQuery die(int eventbits) {
+ EventsListener.getInstance(
+ Element.is(currentContext) ? (Element) currentContext : body).die(
+ eventbits, currentSelector);
+ return this;
+ }
- // bind live delegating event to the current context
+ public GQuery live(String eventName, final Object data, Function... funcs) {
EventsListener.getInstance(
Element.is(currentContext) ? (Element) currentContext : body).live(
- eventName, currentSelector, data, func);
-
+ eventName, currentSelector, data, funcs);
+ return this;
+ }
+
+ public GQuery live(int eventbits, final Object data, Function... funcs) {
+ EventsListener.getInstance(
+ Element.is(currentContext) ? (Element) currentContext : body).live(
+ eventbits, currentSelector, data, funcs);
return this;
}
+
/**
* Binds a handler to a particular Event (like Event.ONCLICK) for each matched
* element. The handler is executed only once for each element.
diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/LazyEvents.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/LazyEvents.java
index 126f6b60..5ce73011 100644
--- a/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/LazyEvents.java
+++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/plugins/LazyEvents.java
@@ -75,7 +75,11 @@ public interface LazyEvents extends LazyBase{
*/
GQuery die(String eventName);
- GQuery live(String eventName, Object data, Function func);
+ GQuery die(int eventbits);
+
+ GQuery live(String eventName, Object data, Function... funcs);
+
+ GQuery live(int eventbits, Object data, Function... funcs);
/**
* Binds a handler to a particular Event (like Event.ONCLICK) for each matched
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 e77540ff..bc7c807f 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
@@ -281,7 +281,7 @@ public class EventsListener implements EventListener {
private Element element;
private JsObjectArray elementEvents = JsObjectArray.createArray().cast();
- private Map liveBindFunctionByEventType = new HashMap();
+ private Map liveBindFunctionByEventType = new HashMap();
private EventsListener(Element element) {
this.element = element;
@@ -328,21 +328,26 @@ public class EventsListener implements EventListener {
bind(b, nameSpace, data, function, -1);
}
}
-
+
public void die(String eventName, String cssSelector) {
- if (eventName == null) {
+ int eventType = "submit".equals(eventName) ? eventType = ONSUBMIT
+ : Event.getTypeInt(eventName);
+ die(eventType, cssSelector);
+ }
+
+ public void die(int eventbits, String cssSelector) {
+ if (eventbits == 0) {
for (LiveBindFunction liveBindFunction : liveBindFunctionByEventType.values()) {
liveBindFunction.removeBindFunctionForSelector(cssSelector);
}
} else {
- LiveBindFunction liveBindFunction = liveBindFunctionByEventType.get(eventName);
+ LiveBindFunction liveBindFunction = liveBindFunctionByEventType.get(eventbits);
liveBindFunction.removeBindFunctionForSelector(cssSelector);
}
}
public void dispatchEvent(Event event) {
-
int etype = "submit".equalsIgnoreCase(event.getType()) ? ONSUBMIT
: DOM.eventGetType(event);
for (int i = 0; i < elementEvents.length(); i++) {
@@ -364,26 +369,28 @@ public class EventsListener implements EventListener {
return getGwtEventListener(element);
}
- public void live(String eventName, String cssSelector, Object data, Function f) {
- int eventType = 0;
- if ("submit".equals(eventName)) {
- eventType = ONSUBMIT;
- } else {
- eventType = Event.getTypeInt(eventName);
- }
+ public void live(String eventName, String cssSelector, Object data, Function... f) {
+ int eventType = "submit".equals(eventName) ? eventType = ONSUBMIT
+ : Event.getTypeInt(eventName);
+ live(eventType, cssSelector, data, f);
+ }
+
+ public void live(int eventbits, String cssSelector, Object data, Function... funcs) {
// is a LiveBindFunction already attached for this kind of event
- LiveBindFunction liveBindFunction = liveBindFunctionByEventType.get(eventName);
+ LiveBindFunction liveBindFunction = liveBindFunctionByEventType.get(eventbits);
if (liveBindFunction == null) {
- liveBindFunction = new LiveBindFunction(eventType, "live");
- eventBits |= eventType;
+ liveBindFunction = new LiveBindFunction(eventbits, "live");
+ eventBits |= eventbits;
sink();
elementEvents.add(liveBindFunction);
- liveBindFunctionByEventType.put(eventName, liveBindFunction);
+ liveBindFunctionByEventType.put(eventbits, liveBindFunction);
}
- liveBindFunction.addBindFunctionForSelector(cssSelector, new BindFunction(
- eventType, "live", f, data));
+ for (Function f: funcs) {
+ liveBindFunction.addBindFunctionForSelector(cssSelector, new BindFunction(
+ eventbits, "live", f, data));
+ }
}
@@ -439,7 +446,7 @@ public class EventsListener implements EventListener {
private void clean() {
cleanGQListeners(element);
elementEvents = JsObjectArray.createArray().cast();
- liveBindFunctionByEventType = new HashMap();
+ liveBindFunctionByEventType = new HashMap();
}
private void sink() {