Hi there,

We have lots of resources to help you with your problem:

Three plugins:

LiveQuery:
http://jquery.com/plugins/project/livequery/

Listen:
http://flesler.blogspot.com/2007/10/jquerylisten.html

Intercept:
http://plugins.jquery.com/project/Intercept

A Frequently Asked Questions page:
http://docs.jquery.com/Frequently_Asked_Questions#Why_do_my_events_stop_working_after_an_Ajax_request.3F

At least one blog article:
http://www.learningjquery.com/2008/03/working-with-events-part-1




--Karl
_________________
Karl Swedberg
www.englishrules.com
www.learningjquery.com



On Apr 15, 2008, at 6:58 AM, lcordier wrote:


Hi, I am trying to bind Ajax click event handlers to links that I have
dynamically
appended to the DOM tree.

Basically I have:

var html = '<tr><td><a href="someurl">text</a></td></tr>'
$("#table > tbody").append(html);

If I try to add click handlers to these anchor tags, they don't work.

 $("a").each(function(i, dom_element) {
   $(dom_element).click(function() {
     $.get('/shopping-cart/remove/'+i+'/', function(xml){
       alert('test: '+i);
       alert($("numbers", xml).text());
     });
     return false;
   });
 });

Anchors that were in the DOM works though.

Reply via email to