我有一个非常简单的问题;我正在开发一个使用过滤插件的wordpress网站。此插件使用ajax加载结果。目标是在灯箱中打开结果(我使用彩色盒)。我可以在第一页上使用它,但在动态添加结果后,它不再起作用。
我知道在ajax加载后我必须重新初始化我的colorbox,插件也提供了一个代码(http://www.designsandcode.com/wordpress-plugins/search-filter-pro/faqs/),我不确定在哪里放置它< /强>
我已将以下内容添加到页面的页脚:
<script>
//detects the start of an ajax request being made
$(document).on("sf:ajaxstart", ".searchandfilter", function(){
console.log("ajax start");
});
//detects when the ajax request has finished and the content has been updated
// - add scripts that apply to your results here
$('.colorbox-link', context).colorbox();
$(document).on("sf:ajaxfinish", ".searchandfilter", function(){
console.log("ajax complete");
//so load your lightbox or JS scripts here again
$('.colorbox-link', context).colorbox();
});
//an event fired when S&F is initialised and S&F scripts have been loaded
$(document).on("sf:init", ".searchandfilter", function(){
console.log("S&F JS initialised");
});
</script>
谢谢!