先上代码。
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>备件查询</title>
<script src="../js/third/flexible.js"></script>
<link rel="stylesheet" href="../CSS/mui.min.css">
<link rel="stylesheet" type="text/css" href="../CSS/search.css"/>
<script>
window.AppInterace.login(252,456,123);
var autoLogin = JSON.parse(window.AppInterace.autologin());
var userId = JSON.parse(window.AppInterace.getCurrentUser());
if(userId[0] !== "true") {
location.href = '../../dlq/login_denglu.html'
window.AppInterace.setNavbarVisiable(0);
} else {
window.AppInterace.setNavbarVisiable(1);
}
</script>
<style></style>
</head>
<body>
<div class="mui-bar mui-bar-nav search">
<span class="mui-icon mui-icon-search"></span>
<input type="text" placeholder="搜索" class="inpSearch">
</div>
<div id="Container" class="mui-content mui-scroll-wrapper con">
<div class="mui-scroll">
<!--数据列表-->
<ul class="mui-table-view mui-table-view-chevron">
</ul>
</div>
</div>
</body>
<script src="../js/third/zepto.min.js"></script>
<script src="../js/xyjplugs/xyjApp.js" type="text/javascript" charset="utf-8"></script>
<script src="../js/third/mui.js"></script>
<script src="../js/xyjplugs/xyjBar.js"></script>
<script src="../js/xyjplugs/xyjrefresh.js"> </script>
<script>
var num = 1;
ajaxAppend(num);
function ajaxAppend (num) {
xyjApp.ajax({
xyjJspname: 'DeviceFiles',
xyjid: 'bjSearch',
pageT: num,
pageSize: '10',
search: $('.inpSearch').val()
},function(data) {
if (data[0] == 'false') {
xyjApp.alert('', data[1],0,2000);
return false;
}
if (data[1].length == 0) {
return 0;
}
appendStr(data[1]);
});
}
function appendStr(strList) {
var str = '';
for ( let i = 0; i < strList.length; i++ ) {
str += `
<li class="mui-table-view-cell imglist">
<div class="mui-media-body">
<p class="mui-ellipsis" >物料名称:${strList[i].WLNAME}</p>
<p>物料编码:${strList[i].MATERIELNO}</p>
<p>库存:${strList[i].CURRENTNUM}</p>
</div>
</li>
`
}
$(".mui-scroll>ul").append(str);
}
window.JsInterace = {
againload: function() {
location.replace(location.href)
}
};
mui.init();
$.xyjBar({
leftIcon: ' ',
title: "备件查询",
})
$.xyjrefresh({
ele: '.mui-scroll-wrapper', // 刷新容器
idDisabledUp: false,// 是否禁用上拉加载
idDisabledDown: true, // 是否禁用下拉刷新
refreshTextUpConfigure: {
callback: function(){
var that = this;
**if (ajaxAppend(++num) == 0) {**
**mui(that.element).pullRefresh().endPullupToRefresh(true);**
**} else {**
**mui(that.element).pullRefresh().endPullupToRefresh(false);**
**}**
}
}
})
$("#Container").height($('body').height() - $('header').height())
$(".search input").on('click',function(){
location.href = './searchS.html'
})
</script>
</html>
上面代码当中的
if (ajaxAppend(++num) == 0) {
mui(that.element).pullRefresh().endPullupToRefresh(true);
} else {
mui(that.element).pullRefresh().endPullupToRefresh(false);
}
如果直接写成mui(that.element).pullRefresh().endPullupToRefresh(true);或者mui(that.element).pullRefresh().endPullupToRefresh(false);就能够显示正在加载或者没有更多数据了的提示语,这是为什么呢?
1 个回复
1***@qq.com (作者)
我把我请求的那部分代码放在了我的callback当中就好了 o~year!