Initialize the jQuery plugin after AJAX content loads

I'm using the PopEasy jQuery plugin to pop up modal forms. I have it working if the trigger links and the DIV containing the modal form are in the main document which uses

$(document).ready(function(){...

to initialize the plugin.

But, I need to trigger the modal from content which is loaded via AJAX, which happens after the main document is "ready".

I've tried

$(document).ajaxComplete(function(){...

but I might be using AJAX in a slightly different way than that method expects?

How can I initialize the plugin after the AJAX content loads?

Answers


You can configure in a success callback once the content were retreived

$.ajax({
  url:"server.aspx",
  type:"POST",
   success:function(result){
   //do it here
   }
});

Need Your Help

Rearrange chain based on window width

javascript jquery html css

Solved: I've got the @EdnilsonMaia answer and adapted it

Xcode - Error creating LLDB target

ios xcode swift lldb beta

I'm getting this error whenever I build in XCode 6 beta 4. It seems to be making my app insanely slow.