I'm doing the following:
I want to add a specific handler for some links, denoted by a class.
$("a.link_list").live("click", new ListLinkHandler());
I use .live instead of .bind because new such links will be generated.
I defined the handler like this: public class ListLinkHandler extends Function { @Override public boolean f(Event e) { [...] } } But it is never visited. I can see the event listener in Chrome Dev Tools: http://screencloud.net/v/bV5V. It's on the body because it's a .live.
I tried using .bind and it worked. The body event listener changed in a a.link_list and the handler does what it's supposed to do, but (I didn't test but as documented) not for newly created links.
So I suppose a bug in the .live implementation.
What version of the product are you using? On what operating system?
Latest from the Downloads page.
Comment #1
Posted on Feb 6, 2013 by Helpful MonkeyThe .live() method is a very important one of jQuery, could someone please make spoort for it a priority?
Comment #2
Posted on Feb 7, 2013 by Grumpy ElephantCould you post a complete example demonstrating the issue? The piece of code you have posted works fine in my example:
public void onModuleLoad() { $("a.link_list").live("click", new ListLinkHandler());
// Add a new link via gquery $("Click ").appendTo(document);
// Add a new link via gwt widgets Anchor a = new Anchor("click"); a.setStyleName("link_list"); a.addClickHandler(new ClickHandler() { public void onClick(ClickEvent event) { Window.alert("clickHandler"); } }); RootPanel.get().add(a); }
public class ListLinkHandler extends Function { @Override public boolean f(Event e) { Window.alert("live"); return true; } }
Comment #3
Posted on Feb 15, 2013 by Grumpy Elephant@stevenroose, just a ping, could you verify if the issue continues?. I would like to close this issue.
Comment #4
Posted on Feb 22, 2013 by Grumpy Elephant(No comment was entered for this change.)
Status: Done
Labels:
Type-Defect
Priority-Medium