Timtech4u / gwtquery

Automatically exported from code.google.com/p/gwtquery
MIT License
0 stars 0 forks source link

.live() method seems broken #173

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
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.

Original issue reported on code.google.com by stevenroose on 6 Feb 2013 at 11:32

GoogleCodeExporter commented 9 years ago
The .live() method is a very important one of jQuery, could someone please make 
spoort for it a priority?

Original comment by stevenroose on 6 Feb 2013 at 11:44

GoogleCodeExporter commented 9 years ago
Could 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
  $("<a class='link_list' href=javascript:alert('href') onClick=alert('onClick')>Click </a>").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;
  }
}

Original comment by manuel.carrasco.m on 7 Feb 2013 at 1:07

GoogleCodeExporter commented 9 years ago
 @stevenroose, just a ping, could you verify if the issue continues?. I would like to close this issue.

Original comment by manuel.carrasco.m on 15 Feb 2013 at 1:33

GoogleCodeExporter commented 9 years ago

Original comment by manuel.carrasco.m on 22 Feb 2013 at 3:03