iscroll jQuery插件:

页面布局:





下拉刷新…






















多拉起…




分页是一种Ajax请求,它将页面号传递给一般的处理程序,并在一般处理程序中分页后返回数据以返回JSON数组对象。

下拉刷新:



*下拉刷新(自定义实现此方法)
*(myscroll。刷新); / /数据加载完成后,调用接口的更新方法
* /
功能pulldownaction(){
setTimeout(){()函数(
李,我;
EL = document.getelementbyid('thelist);
/ / ==========================================
$ ajax({
键入:获取
网址:负载量.ashx
数据:{页:generatedcount },
DataType:JSON
成功:函数(数据){
var =数据;
$(JSON),每个(函数(){)
李= document.createelement(李的);
/ / li.innertext = 'generated +行'(+ + generatedcount);
li.innerhtml =;
el.insertbefore(李,埃尔。子{ 0 });
})
}
});
(myscroll。刷新); / /数据加载完成后,记得打电话界面更新方法更新内容时加载(即:Ajax完成)
},1000); / /模拟网络拥塞消除setTimeout从生产!
}


上拉刷新


功能pullupaction(){
setTimeout(){()函数(
李,我;
EL = document.getelementbyid('thelist);
/ / ==========================================
$ ajax({
键入:获取
网址:负载量.ashx
数据:{页:generatedcount },
DataType:JSON
成功:函数(数据){
var =数据;
$(JSON),每个(函数(){)
李= document.createelement(李的);
/ / li.innertext = 'generated +行'(+ + generatedcount);
li.innerhtml =;
el.insertbefore(李,埃尔。子{ 0 });
})
}
});
/ / ============================================
(myscroll。刷新); / /数据加载完成后,记得打电话界面更新方法更新内容时加载(即:Ajax完成)
},1000); / /模拟网络拥塞消除setTimeout从生产!
}


初始化



*初始化iscroll控制
* /
函数加载(){
pulldownel = document.getelementbyid('pulldown);
pulldownoffset = pulldownel.offsetheight;
pullupel = document.getelementbyid('pullup);
pullupoffset = pullupel.offsetheight;
myscroll =新iscroll('wrapper,{
ScrollbarClass:'myscrollbar ' / * * /风格
usetransition:假,
TopOffset:pulldownoffset,
OnRefresh:函数(){
如果(pulldownel.classname.match('loading ')){
pulldownel.classname =;
pulldownel.queryselector('。pulldownlabel).innerHTML =下拉刷新…;
} else if(pullupel.classname.match('loading ')){
pullupel.classname =;
pullupel.queryselector('。pulluplabel).innerHTML =拉更多…;
}
},
OnScrollMove:函数(){
如果(y = 5)!pulldownel.classname.match('flip ')){
pulldownel.classname = 'flip;
pulldownel.queryselector('。pulldownlabel).innerHTML =松手开始更新;
this.minscrolly = 0;
} else if(这个Y<5 pulldownel.classname.match('flip ')){
pulldownel.classname =;
pulldownel.queryselector('。pulldownlabel).innerHTML =下拉刷新…;
this.minscrolly = - pulldownoffset;
} else if(这个Y<(this.maxscrolly - 5)!PullUpEl.className.match ('flip')) {
pullupel.classname = 'flip;
pullupel.queryselector('。pulluplabel).innerHTML =松手开始更新;
this.maxscrolly = this.maxscrolly;
} else if(这个y >(this.maxscrolly + 5)pullupel.classname.match('flip ')){
pullupel.classname =;
pullupel.queryselector('。pulluplabel).innerHTML =拉更多…;
this.maxscrolly = pullupoffset;
}
},
OnScrollEnd:函数(){
如果(pulldownel.classname.match('flip ')){
pulldownel.classname = 'loading;
pulldownel.queryselector('。pulldownlabel).innerHTML =负荷…;
(pulldownaction); / /执行自定义函数(Ajax调用)
} else if(pullupel.classname.match('flip ')){
pullupel.classname = 'loading;
pullupel.queryselector('。pulluplabel).innerHTML =负荷…;
(pullupaction); / /执行自定义函数(Ajax调用)
}
}
});
setTimeout(function(){ document.getelementbyid('wrapper)。style.left = 0;},800);
}
/ /初始化绑定iscroll控制
Document.addEventListener('touchmove功能(e){ e.preventDefault();},假);
Document.addEventListener('domcontentloaded,装,假);