Scrolling loading is a good thing, which can solve the embarrassment of loading too much at a time. In fact, it is just a disguised pagination. To summarize the usage of this wheel, it is quite simple.
First is the html structure:
<div class=" saleRecord panelList clear" style="position:relative;height:400px;"> <div > <div > <ul > @foreach (var item in ViewBag.***) { if ( == true) { <li> <div class="panelListItemForALL"> <table class="allRecordTable"> <tbody> <tr> <td>***</td> <td>@item.***</td> </tr> <tr> <td>***</td> <td>@item.***</td> </tr> <tr> <td>***</td> <td>@item.***</td> </tr> </tbody> </table> </div> </li> } } </ul> <div >Load more</div> </div> </div>
Then there is the css style:
#wrapper { position: absolute; z-index: 1; top: 0; bottom: 0; left: 0; width: 100%; overflow: hidden; } #scroller { position: absolute; z-index: 1; -webkit-tap-highlight-color: rgba(0,0,0,0); width: 100%; -webkit-transform: translateZ(0); -moz-transform: translateZ(0); -ms-transform: translateZ(0); -o-transform: translateZ(0); transform: translateZ(0); -webkit-touch-callout: none; -webkit-user-select: none; -moz-user-select: none; -ms-user-select: none; user-select: none; -webkit-text-size-adjust: none; -moz-text-size-adjust: none; -ms-text-size-adjust: none; -o-text-size-adjust: none; text-size-adjust: none; } #more { text-align:center; }
If necessary, put position:relative attribute on the parent element
Finally, the initialization and acquisition of data in the script:
var pagenum = 1, update = true, id=ID; var myScroll; setTimeout(function(){ myScroll = new IScroll('#wrapper', { mouseWheel: true, click: true }); ('scrollEnd', function () { //( +"|||"+); //If slide to the bottom, more data will be loaded (10px height from the bottom) if (( - ) == 0) { getMore(); } }); },100 ); function getMore() { var that = ("more"); pagenum++; $.ajax({ url: '/***/getPage', data: {'currentPage':pagenum,'id':id}, type: 'POST', datatype: "json", success: function (data) { //alert(data); var list = ; if ( < 1) { pagenum--; = "No more..."; return; } var ul = ("thelist"); for (var i = 0; i < ; i++) { var str = "<li>"; str += "<div class=\"panelListItemForALL\"><table class=\"allRecordTable\"><tbody><tr><td>***</td><td>"+list[i].OrderCode+"</td>"; str += "</tr><tr><td>***</td><td>"+list[i].GoodsName+"</td></tr>"; str += "<tr><td>***</td><td>"+ [i] +"</td>"; str += "</tr></tbody></table></div>"; str += "</li>"; += str; (); } } }); }
Just fill in the corresponding data. Of course, the controller needs to write a page to obtain data, and obtain it through ajax here.
The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.