下拉刷新
第一:
1 2 3 4 5 6 7 8 9 | mui.init({ pullRefresh: { container: '#pullrefresh' , up: { contentrefresh: '正在加载...' , callback: pullupRefresh } } }); |
第二:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | var i = 0; var count = 0; var number = 1; function pullupRefresh(){ setTimeout( function (){ $( function (){ var json = {}; json.competitionID = CompetitionID; json.fightTypeID = fightTypeID; json.action = 'getFightType' ; $.post( 'http://192.168.3.12:11000/api/Competition' , json, function (e){ var obj = eval( "(" + e + ")" ); var data = obj.data[0].v_teamfight; if (number > data.length){ number = data.length; } var counts = parseInt(data.length/2)+1; //定义上拉次数 mui( '#pullrefresh' ).pullRefresh().endPullupToRefresh((++count >counts)); //判定是否拖动 for (i; i < number; i++){ var str = '' ; str += "<span>" + data[i].TeamAName + "</span>" ; //A队名称 str += "</div><div>vs</div><div>" ; str += "<img src='../../img/hwq/gold.png'/>" ; //B队logo路径(暂无) str += "<span>" + data[i].TeamBName + "</span>" ; //B队名称 $( "#content" ).append(str); } number+=1; }); }); },100); } |
第三:
1 2 3 4 5 6 7 8 9 10 11 12 | if (mui.os.plus){ mui.plusReady( function (){ setTimeout( function (){ mui( '#pullrefresh' ).pullRefresh().pullupLoading(); },10); }); } else { mui.ready( function () { mui( '#pullrefresh' ).pullRefresh().pullupLoading(); }); } |