2011-12-22 15 views
3

jqueryモバイルプロジェクトで作業中です。私は2つのhtmlページを持っています。 index.htmlから私はpage.htmlにスワイプレフトイベントを持っており、うまくいきます。 page.htmlから私はswiperightにしたいのでindex.htmlに戻ってきますが、うまくいきません。jquery mobileで別のHTMLページにスワイプする方法

コードは、単一のドキュメント内の内部ページ間をスワイプするとうまく動作しますが、htmlページ間ではうまく動作しません。そして、私はいくつかのHTMLページを使用する必要があります。

これは誰でも利用できますか?答えに感謝します。

私のindex.htmlページでは、このI私スワイプコード:

<script> 
$(document).ready(function() { 

$("#main").bind('swipeleft',function(event, ui){ 
     $.mobile.changePage("page.html", "slide"); 
}) 

}) 
</script> 

をそして、これは私のpage.htmlのための私のコードです:

<script> 
$(document).ready(function() { 

$("#main").bind('swiperight',function(event, ui){ 
     $.mobile.changePage("index.html", "slide"); 
}) 

}) 
</script> 

答えて

0

あなたは$ .ready(使用しないでください)代わりにpageInit()を使用してください。
また、ページのすべてのidsが、ページ固有のものではなく、すべてのページで一意であることを確認してください。私はここに求めている

0

私はすべてのページでその作品が細かいスワイプで移動するには、次のすべてのページ上のコードの下に使用していますが、何のスライドアニメーションは、彼らではありません。

$("#main").bind('swipeleft',function(event, ui){ 
     goPage1(); 
}) 
$("#main").bind('swiperight',function(event, ui){ 
     goPage2(); 
}) 

function goPage1(){ 
    var dirPath = dirname(location.href); 
    var fullPath = dirPath + "/page1.html"; 
    window.location=fullPath; 
} 

function goPage2(){ 
    var dirPath = dirname(location.href); 
    var fullPath = dirPath + "/page2.html"; 
    window.location=fullPath; 
} 
function dirname(path){ 
    return path.replace(/\\/g,'/').replace(/\/[^\/]*$/, ''); 
} 
関連する問題