0
我使用jQuery的滚动分页插件动态加载额外的内容工作的一个项目滚动时:https://github.com/andferminiano/jquery-scroll-pagination的Javascript:如何防止loadscrollPagination功能被加载多次
这样做是为了方便用户有不同的看法。这目前正在通过使用jquery加载事件来完成,当用户单击按钮时,内容将被加载。
我面临的问题是“scrollPagination”函数保留在内存中,并在#content上处于活动状态。如果用户点击视图并切换回来,第二次加载#content的scrollPagination。所有的呼叫都被执行两次。
问题:有没有办法阻止scrollPagination函数被激活多次?谢谢你的帮助!
function loadscrollPagination() {
setTimeout(function() {
$('#content').scrollPagination({
nop: 10, // The number of posts per scroll to be loaded
offset: 0, // Initial offset, begins at 0 in this case
error: 'No More Posts!', // When the user reaches the end this is the message that is
delay: 500, // When you scroll down the posts will load after a delayed amount of time.
scroll: true // The main bit, if set to false posts will not load as the user scrolls.
});
}, 100);
}
$("div.detail").click(function() {
$('section').load('detailed-view.php', function() {
loadscrollPagination();
});
});