views:

48

answers:

3

Hi folks,

I have a set of list items in unordered lists that I bind the anchors inside them to fire when clicked. The thing is: Some ul's are created (via ajax) when I click on some of the li's created in the first place, binded in the jQuery's document.ready. And I want this li's that are created dinamically to fire as well. Can I do that?

Well, I hope you get what i mean...

Thks in advance.

Aldo

+2  A: 

I think you are looking for live().

Vivin Paliath
+6  A: 

Check out live() method

Use it the same way as bind(), ie :

$('.class').live('click', function() { 
     alert('bla');
   }
);
Boris Guéry
+2  A: 

The live() event will work on all ul elements even if you create them after you bind the live method to them. Like so:

$('ul').live('click', function() {
  // your code here...
}

See the info on live here.

skymook