$.ready(function() {
//循环初始化所有下拉刷新,上拉加载。
$.each(document.querySelectorAll('.mui-slider-group .mui-scroll'), function(index, pullRefreshEl) {
console.log(JSON.stringify(pullRefreshEl))
if(index == 0) { //评论页面的上拉刷新、下拉加载
$(pullRefreshEl).pullToRefresh({
down: {
callback: function() {
var self = this;
setTimeout(function() {
var storage = window.localStorage;
storage.setItem("clickBtn", "plBtn");
pl_key_array = new Array();
// location.reload(true);
pullRefreshPl();//自定义加载数据
self.endPullDownToRefresh();
}, 500);
}
},
up: {
callback: function() {
var self = this;
console.log(JSON.stringify(this))
console.log("pl_flg---->" + pl_flg);
if(pl_flg == true) {//判断是否有更多数据
self.endPullUpToRefresh(true); //为true时表示没有更多数据
} else {
setTimeout(function() {
pullDown();//自定义加载数据
self.endPullUpToRefresh();
}, 500);
}
}
}
});
} else if(index == 1) { //点赞标签上拉刷新、下拉加载
$(pullRefreshEl).pullToRefresh({
down: {
callback: function() {
var self = this;
setTimeout(function() {
var storage = window.localStorage;
storage.setItem("clickBtn", "plBtn");
// location.reload(true);
pullRefreshZan();//自定义加载数据
self.endPullDownToRefresh();
}, 500);
}
},
up: {
callback: function() {
var self = this;
if(zan_flg == true) {//判断是否有更多数据
self.endPullUpToRefresh(true); //为true时表示没有更多数据
return;
} else {
pullDownZan();//自定义加载数据
self.endPullUpToRefresh();
}
}
}
});
}
});
});
需求是选项卡分开加载数据,分开上拉加载下拉刷新,请问各位大佬怎么能在上拉或下拉时在数据中判断是否有更多数据,现在的解决办法需要初始第二次上拉加载才能判断显示有没有更多数据,这个是一个公共页面,有好几个接口,不是单一接口加载数据
问题已解决:
<div id="tabGroup" class="mui-slider-group">
<div id="item1mobile" class="mui-slider-item mui-control-content">
<div id="scroll1" class="mui-scroll-wrapper">
<div class="mui-scroll" id="common_pl">
<ul id="hotList" class="pl-hot-list">
<div id="" class="pl-tag">
<img class="pl-img-blue" src="../../../ui/qz/images/pl_left.png" />
<p class="pl-p-top" id="hot_list"></p>
</div>
<div id="hotTalk"></div>
</ul>
<ul class="pl-all-list" id="allUl">
<div class="pl-tag">
<img id="pl_all" class="pl-img-blue" src="../../../ui/qz/images/pl_left.png" />
<p class="pl-p-top" id="qb_list"></p>
<div id="allList"></div>
</div>
<div id="allTalks"></div>
</ul>
</div>
</div>
</div>
<div id="item2mobile" class="mui-slider-item mui-control-content ">
<div id="scroll2" class="mui-scroll-wrapper">
<div class="mui-scroll" id="common_zan">
<ul id="zanList" class="pl-zan-list">
<div id="zanDiv"></div>
</ul>
</div>
</div>
</div>
</div>
如上,给对应的选项卡加上ID,如<div class="mui-scroll" id="common_zan">,然后再请求数据时用mui('#common_zan').pullToRefresh().endPullUpToRefresh(true);去控制