Adi*_*Adi 6 jquery jquery-mobile iscroll4
我正在努力让我的头发试图让iscroll 4与jQuery Mobile合作.
一切正常,我禁用JQM ajax默认导航,但我想保留这个.
我的问题是我无法解决如何成功调用/绑定iscroll所以它适用于需要它们的页面.我试过pageinit()和pagecreate()无济于事.
任何指针都非常赞赏.
一个.
我在pageshow
和orientationchange
事件上初始化/刷新iScroll实例.我在data-role="content"
div 上设置了一个我想要滚动的类(在这个例子中我使用了这个.content
类).
var myScroll = [];
$(document).delegate('[data-role="page"]', 'pageshow', function () {
if ($.mobile.activePage.find('.content').length > 0) {
if (this.id in myScroll) {
myScroll[this.id].refresh();
} else {
myScroll[this.id] = new iScroll($.mobile.activePage.find('.content')[0].id, {
hScroll : false,
vScroll : true,
hScrollbar : false,
vScrollbar : true,
fixedScrollbar : true,
fadeScrollbar : false,
hideScrollbar : false,
bounce : true,
momentum : true,
lockDirection : true
});
}
}
});
$(window).bind('orientationchange', function () {
if ($.mobile.activePage[0].id in myScroll) {
myScroll[$.mobile.activePage[0].id].refresh();
}
});
Run Code Online (Sandbox Code Playgroud)