Pawan
Pawan

Reputation: 32331

why the trigger click is not working in this case

I have a Menu and i am clciking on it using the line

  $("#swipecontainer .swiper-slide").eq(centervalue).trigger("click");

But i see that never the event listener is getting fired .

This is my code

 $(document).on("click", ".swiper-slide", function() {
        alert('i am called');
    });

http://jsfiddle.net/cod7ceho/61/

Could you please let me know how to resolve this .

Upvotes: 0

Views: 52

Answers (1)

Milind Anantwar
Milind Anantwar

Reputation: 82241

You need to define the event before making the call to it.

 $(document).on("click", ".swiper-slide", function() {
      alert('i am called');
 });
 $("#swipecontainer").append(favoriteresultag).trigger("create");
 $("#swipecontainer .swiper-slide").eq(centervalue).trigger("click");

http://jsfiddle.net/nx33jez6/

Upvotes: 1

Related Questions