<body>
<div class="mui-content">
<!--搜索框 start-->
<div class="header">
<div class="srk">
</div>
</div>
<!--搜索框 end-->
<!--选项卡 start-->
<div id="slider" class="mui-slider mui-fullscreen">
<div id="sliderSegmentedControl" class="mui-scroll-wrapper mui-slider-indicator mui-segmented-control mui-segmented-control-inverted">
<div class="mui-scroll lst-tit-tab" id="muiTab">
<a id="default" class="mui-control-item pro-lst-tit mui-active" href="#">默认</a>
<a id="soldnum" class="mui-control-item pro-lst-tit" href="#">人气</a>
<a id="comment" class="mui-control-item pro-lst-tit" href="#">好评</a>
<a id="cp" class="mui-control-item pro-lst-tit" href="#">价格</a>
</div>
</div>
<div class="mui-slider-group" id="pullrefresh">
<div id="item1mobile" class="mui-slider-item mui-control-content mui-active">
<div id="scroll1" class="mui-scroll-wrapper">
<div class="mui-scroll">
<ul class="mui-table-view" id="goodsList">
<!--row1-->
<!--row2-->
</ul>
</div>
</div>
</div>
</div>
</div>
<!--选项卡 end-->
<!--底部 start-->
<div class="block1"></div>
<a class="fhdb" id="gotop" href="javascript:void(0)">
<div class="totop-bg">
<p>顶部</p>
</div>
</a>
<!--底部 end-->
</div>
<script type="text/javascript">
//mui初始化
mui.init();
//上拉加载
(function($) {
//阻尼系数
var deceleration = mui.os.ios?0.003:0.0009;
$('.mui-scroll-wrapper').scroll({
bounce: false,
indicators: true, //是否显示滚动条
deceleration:deceleration
});
$.ready(function() {
//循环初始化所有下拉刷新,上拉加载。
$.each(document.querySelectorAll('.mui-slider-group .mui-scroll'), function(index, pullRefreshEl) {
$(pullRefreshEl).pullToRefresh({
/ down: {
callback: function() {
var self = this;
setTimeout(function() {
var ul = self.element.querySelector('.mui-table-view');
ul.insertBefore(createFragment(ul, index, 10, true), ul.firstChild);
self.endPullDownToRefresh();
}, 1000);
}
}, /
up: {
callback: function() {
var self = this;
setTimeout(function() {
var ul = self.element.querySelector('.mui-table-view');
ul.appendChild(createFragment(ul, index, 6));
self.endPullUpToRefresh();
}, 1000);
}
}
});
});
var createFragment = function(ul, index, count, reverse) {
var length = ul.querySelectorAll('li').length;
var fragment = document.createDocumentFragment();
var cells = document.body.querySelectorAll('.mui-table-view-cell');
var li;
mui.ajax({
cache: false,
type: "POST",
url:"${url}/goodsListAjax.jspx",
data:{'keyword':'${keyword }','icode':'${icode }','code':'${mbAppCategoryCode}'},
async: false,
dataType:"json",
error: function(request) {
alert("请稍后再试!");
},
success: function(data) {
for (var i = cells.length, len = i 4; i < len; i ) {
li = document.createElement('li');
li.className = 'mui-table-view-cell pro-box';
li.innerHTML = '<a class="pro-img-box" href="${url }/goodsDetail.jspx?id=' data[i].id '">';
li.innerHTML ='<img src="' data[i].titleImage '"></a>';
li.innerHTML ='<div class="proname-box">';
li.innerHTML ='<p class="color3 proname ft12">' data[i].title '</p></div>';
li.innerHTML ='<div class="mui-col-sm-12 mui-col-xs-12 lh"><div class="mui-col-sm-8 mui-col-xs-9 mui-pull-left pro-price"><p class="mui-pull-left color10 ft14">¥' data[i].currentPrice.toFixed(2) '</p></div><a href="#" class="mui-col-sm-2 mui-col-xs-2 mui-pull-right gwc"><img src="${resBaseUrl}/css/microMall/svg/car-add.svg"></a></div>';
fragment.appendChild(li);
}
}
});
return fragment;
};
});
})(mui);
</script></body>
1 个回复
cqy123 (作者)
已经解决了,self.endPullUpToRefresh();里面加个判断条件就可以了