应用插件来DOM中的一个新元素(jQuery的) [英] apply plugin to a new element in the DOM (jquery)
本文介绍了应用插件来DOM中的一个新元素(jQuery的)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用jQuery tablesorter插件并将其应用到一个表ID:#table
I am using the jquery tablesorter plugin and applies it to a table with id : #table
我的搜索功能请求通过AJAX的结果和替换表具有相同ID的新表
my search facility requests for results via ajax and replaces the table with a new table of the same id
如果我的code是这样的:
if my code is like this :
$('#table').tablesorter();
我该怎么添加应用,使新的表插件的工作? (我知道jQuery的现场活动,但如何使用,在这种情况下?
what do I add to apply to make the plugin work on the new table? (I know of jquery's live event, but how do I use that in this case?
推荐答案
您必须重新运行 $('#表)的tablesorter();
搜索后请求已完成。
you have to re-run $('#table').tablesorter();
after search request completed.
$.ajax({
type: "POST",
url: "search.php",
data: "query=blabla",
success: function(html){
// replace old table with new table
// re-apply table sorter
$('#table').tablesorter();
}
});
这篇关于应用插件来DOM中的一个新元素(jQuery的)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文