KJA
KJA

Reputation: 753

popup is not working after ajax response

I am using jquery popup , but it's not working after loading it from ajax

the popup.js is between

   $(document).ready(function() {
    $('a.poplight[href^=#]').click(function() {
     // code here
     }
    });

Do I have to use delegate?
Is it a problem because the document ready?

NOTE :
I tried to remove the document ready and used this

    $(document).delegate("a.poplight[href^=#]",'click',function(e){
// code here
}

but it doesn't work

any help ?

Regards

Upvotes: 1

Views: 736

Answers (1)

thecodeparadox
thecodeparadox

Reputation: 87073

You can try this

(jQuery >= 1.7)

$(document).on('click',"a.poplight[href^=#]",function(e){
// code here
});

OR

$('a.poplight[href^=#]').live(function() {
     // code here
});

OR

$('body').delegate('a.poplight[href^=#]', 'click', function() {
     // code here
});

Upvotes: 2

Related Questions