From 69ab01e7d6bba1d8bfd0783b33ad231650ecf5d8 Mon Sep 17 00:00:00 2001 From: jdramaix Date: Wed, 17 Dec 2014 11:17:28 +0100 Subject: improve off and on methods --- .../src/main/java/com/google/gwt/query/client/GQuery.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'gwtquery-core/src/main/java') diff --git a/gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java b/gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java index 09e69fe3..7f5bbf82 100644 --- a/gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java +++ b/gwtquery-core/src/main/java/com/google/gwt/query/client/GQuery.java @@ -3236,6 +3236,10 @@ public class GQuery implements Lazy { * Attach an event handler function for one or more events to the selected elements. */ public GQuery on(String eventName, String selector, Function... funcs) { + if (selector == null || selector.isEmpty()) { + return on(eventName, funcs); + } + return delegate(selector, eventName, funcs); } @@ -3243,6 +3247,10 @@ public class GQuery implements Lazy { * Attach an event handler function for one or more events to the selected elements. */ public GQuery on(String eventName, String selector, Object data, Function... funcs) { + if (selector == null || selector.isEmpty()) { + return on(eventName, data, funcs); + } + return delegate(selector, eventName, data, funcs); } @@ -3250,7 +3258,7 @@ public class GQuery implements Lazy { * Remove all event handlers. */ public GQuery off() { - return as(Effects).off(); + return as(Events).off(); } /** @@ -3271,6 +3279,9 @@ public class GQuery implements Lazy { * Remove an event handler */ public GQuery off(String eventName, String selector) { + if (selector == null || selector.isEmpty()) { + return off(eventName); + } return undelegate(selector, eventName); } -- cgit v1.2.3