开发者

Jquery plugins not working on ajaxed content

开发者 https://www.devze.com 2022-12-25 00:36 出处:网络
I have some con开发者_如何学编程tent that I am loading using jquery ajax. The content has jquery plugins attached (example a modal box).

I have some con开发者_如何学编程tent that I am loading using jquery ajax. The content has jquery plugins attached (example a modal box).

My problem is that because the ajaxed content isn't part of the original dom it hasn't had the plugins applied to it.

How do I apply the plugins to ajaxed content??? Is there someway I can reinitialize i the plugins???


You can call the plugin in the ajax success function like this:

$.ajax({
  //Stuff..
  success: function(data) {
    $(".selector", data).myPlugin();
  }
});

This calls the plugin on the matching selector only in the html that was returned, so it won't run on the rest of the page again.

0

精彩评论

暂无评论...
验证码 换一张
取 消