私は/ 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();
}
});
あなたが<スクリプトSRC = "http://code.jquery.com/mobile/1.0rc1/jquery.mobile-1.0rc1.min.js">の前にiscroll JSを読み込むか? – Adi
いいえ、最後にロードするスクリプトです。 iScrollのインスタンスを初期化するのに苦労している場合は、iScrollサイトのサンプルに従っていることを確認してください。 iScollは、呼び出す要素の直接の子をスクロールします。 – Jasper
JQM ajaxナビゲーションでは機能しません。つまり、iscrollが動作していないページに移動した場合です。私はそのページをリフレッシュすると正常に動作します(これはすべてのjを再度読み込むためです)。現在のiscroll jsはHTMLの頭にあり、jsのページイベントではありません – Adi