尝试启用滑动到left.html或right.html

时间:2014-09-06 22:37:46

标签: jquery jquery-mobile cordova

有三页index.html和right.html以及left.html

$.mobile.loadPage( "right.html" ).loadPage( "left.html" );  // for page prefetching 

$(document).on( "swiperight" ,  function( ) 
                                   {
    $.mobile.changePage( "right.html", { transition: "slide" , reverse: true } );
                                   }                
                );


$(document).on( "swipeleft" ,   function( ) 
                                   {
    $.mobile.changePage( "left.html", { transition: "slide" , reverse: true } );
                                   }

                );

如果我更换

 $.mobile.changePage( "left.html", { transition: "slide" , reverse: true } );

 alert("swipeleft");

它确实显示了一个警告窗口,上面写着“swipeleft”

那么以下代码是否正确?

$.mobile.pageContainer.pagecontainer("load", "left.html");
$.mobile.pageContainer.pagecontainer("load", "right.html");


// Enabling Swype

$(document).on( "swiperight" ,  function( ) 
                            {

$.mobile.pageContainer.pagecontainer("change", "right.html", { transition: "slide" , reverse: true } );

                            }

                            );

$(document).on( "swipeleft" ,   function( ) 
                            {

$.mobile.pageContainer.pagecontainer("change", "left.html", { transition: "slide" , reverse: true } );

                            }

                            );

顺便说一句,目录就像这样

上面的源代码保存在一个名为js的目录中,与js文件夹在同一级别,有三个html文件

那么它必须是“../left.html”而不是“left.html”

非常感谢!

0 个答案:

没有答案