I'm trying to do the following:
I want to add a specific handler for some links, denoted by a class.
$("a.link_list").live("click", new ListLinkHandler());
I need .live()
instead of .bind()
because new such links will be generated. (I know jQuery's .live()
is deprecated in favor of .on()
, but gwt-query doesn't have a .on()
yet.)
I defined the handler like this (just as the gwtquery example does):
public class ListLinkHandler extends Function {
@Override
public boolean f(Event e) { [...] }
}
However, the handler method is never called when I click the links.
I can see the event listener in Chrome Dev Tools: http://screencloud.net/v/bV5V. I think it's on the body
because it's a .live()
.
I tried using .bind()
and it worked fine. The body
event listener changed in a a.link_list
and the handler does what it's supposed to do, but (as documented, I didn't test) not for newly created links.
I filed a bug for the .live()
method, but maybe I'm doing something wrong.
Also, I have no idea how to do it without gwtquery, GWT doesn't seem to have a method for selecting elements by class, neither to continually add the listener to new elements.