开发者

How to get a jQuery plugin to still identify an element after it was added to the DOM through AJAX

开发者 https://www.devze.com 2023-03-31 12:38 出处:网络
OK, so I am having some trouble getting my head round a solution to get a certain jQuery plugin to work after an AJAX call has been successful and placed the data into the DOM.

OK, so I am having some trouble getting my head round a solution to get a certain jQuery plugin to work after an AJAX call has been successful and placed the data into the DOM.

The plugin is jScroll and I am sure that this plugin only identifies th开发者_Python百科e element call upon on page load, so if the element is loaded into the DOM through the AJAX call the plugin will not recognise the it thus not working.

I sthere any way round this that does not require a re-writing of the code?


Could you do something like -

$.get('ajax/test.html', function(data) {
  $('.result').html(data);
  $('.result').jscroll()
});

Which would get the result from the server add it to an element, then set up the jScroll functionality on that element.

0

精彩评论

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