Mui top slide refresh and drop-down loading example

Source: Internet
Author: User
Tags call back

1. First, you must bind a Mui-scroll-wrapper style and a container ID to a slide element.

For example

    

<div class="mui-content mui-scroll-wrapper" id="refreshContainer"><ul id="siteList"></ul>                 </div>

2. Configure the drop-down and slide-up components.

VaR flag = false; Mui. init ({pullrefresh: {container: "# refreshcontainer", // refresh the container ID from the drop-down list. You can use CSS selectors that queryselector can locate, such as ID and ,. class, etc. up: {Height: 10, // optional. the default value is 50. trigger pull load drag distance contentrefresh: "loading... ", // optional. When loading, the title content displayed on the pull-up control contentnomore: 'No More data' is displayed. // optional, the reminder content displayed when the request is complete without more data; Auto: false, // optional, default: false. call back: upperskid // required, refresh function, written according to specific business, for example, get new data from the server through Ajax;}, down: {style: 'circle', // required, pull-down refresh sample Type. Currently, the native 5 + 'circle' style color: '# 2bd009' is supported. // optional. The default "#2bd009" drop-down refresh control color Height: '50p ', // optional. The default value is 50px. the height of the pull-down refresh control, range: '100px ', // optional, default: 100px. The range of the drag-down control can be offset: '0px', // optional, default: 0px, the start position of the pull-down refresh control is Auto: false, // optional. The default value is false. call back: refresh // required, refresh function, written according to specific business, for example, get new data from the server through Ajax ;}}}); function refresh () {flag = false; Mui ('# refreshcontainer '). pullrefresh (). refresh (true); resetdata (); setTimeout (function () {Getsitedata () ;}, 500) ;}function upperskid () {// Mui ('# sitelist '). pullrefresh (). endpulluptorefresh (FLAG); // If the parameter is true, no more data is available. Page = pagesize * indexnum; setTimeout (function () {Mui ('# refreshcontainer '). pullrefresh (). endpulluptorefresh (FLAG); // If the parameter is true, no more data is available. Getsitedata ();}, 500 );}

3. Data Retrieval Interface

Function getsitedata () {$. ajax ({URL: "url", type: "Get", data :{}, datatype: "jsonp", // specify the Data Type jsonp: 'callback' returned by the server ', success: function (data) {var result = JSON. parse (data); // converts a JSON object to a string if (result. total> 0) {sitelistdata = sitelistdata. concat (result. rows); showdata (sitelistdata); // render data function} else {sitelistdata = []; showdata (sitelistdata);} If (flag = false) {indexnum ++ ;} if (result. rows. length <pagesize) {// determines whether there is no data flag = true} Mui ('# refreshcontainer') if the number of retrieved data is smaller than the number of queries per page '). pullrefresh (). endpulldown ();}});}

  

  

Mui top slide refresh and drop-down loading example

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.