Tess
Tess

Reputation: 23

JCarousel - Items added with add() do not respond to .click()

I am loading items to a carousel (based on another carousel click event) using something like this:

    testCarousel.stopAuto();
testCarousel.reset();
testCarousel.add(0,"<LI>TEST</LI>");
testCarousel.add(1,"<LI>TEST2</LI>");
testCarousel.size(2);

The items are displayed properly. but the testCarousel onclick event on the <li>'s never gets called! On the other hand, if I'm adding the items using static html <li>, the click event DOES get called.

Heres an example of the click function:

$("#test-carousel li").click(function () {
alert("CLICKED!");      

});

Is there some function I have to call to make the <li> items added to the carousel using add() launch the click event when clicked? Or maybe it should be handled differently ?

All needed items are on the form, no ajax calls.

I searched everywhere but no example or solution for my case.

Thanks!

Upvotes: 2

Views: 2867

Answers (1)

Andy
Andy

Reputation: 30135

$("#test-carousel li").live('click',function () {
    alert("CLICKED!");      
});

http://api.jquery.com/live/

Upvotes: 3

Related Questions