对于无限滚动,我基于带有数据库API集的mixitup插件的过滤器生成url。
初始化无限滚动
function InitializeInfiniteScroll() {
var $infinite = jQuery('.mixitup').infiniteScroll({
path: function() {
return global.url +
"¶m1="+ global.param1 +
"¶m2="+global.param2 +
"¶m3=" + global.param3
},
// load page as text
responseType: 'json',
// disable history
history: false,
status: '.page-load-status',
checkLastPage: false
});
$infinite.on( 'load.infiniteScroll', function( event, response ) {
if(response.length > 0) {
if(global.dataset === null) {
global.dataset = response;
} else {
global.dataset = global.dataset.concat(response);
}
global.mixer.dataset(global.dataset);
global.last_id = response[response.length-1].id;
} else {
global.lastp = 1;
jQuery('.mixitup-container').infiniteScroll('lastPageReached');
}
});
}
在混合控制中,我称它为:
//global params1 params2 params3 set
if(global.lastp === 1) {
jQuery('.mixitup').infiniteScroll('destroy');
InitializeInfiniteScroll();
lxdata.last_page = 0;
} else {
jQuery('.mixitup').infiniteScroll('loadNextPage');
}
我有一个问题,我在调用lastPageReached beiing之后无法调用loadNextPage。我不知道如何正确地将无限滚动视图重置为适当的另一个,以使用另一个数据列表。
这样,我得到一个错误:
Uncaught TypeError: o._init is not a function
最佳答案
以下答案对我有用(无限滚动V3)。试图投票,但我的声誉很低。
只是澄清一下:
const infiniteScrollContainer = $('#your_container').data('infiniteScroll');
infiniteScrollContainer.enableScrollWatch();
infiniteScrollContainer.canLoad=true;
avatarScroll.pageIndex = 1;
avatarScroll.loadCount = 0;
infiniteScrollContainer.loadNextPage();
关于javascript - 无限滚动:: mixitup::json和ajax控件,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/49674983/