使用$ .mobile.changePage应用jquery移动页面转换

时间:2012-08-21 03:12:42

标签: jquery-mobile

所以我想要实现的是,在手动创建页面更改时应用任何页面转换。

所以例如,在我的网页上说,我这样做,以便当用户向右滑动时,网站会转到第二页......就像这样

$('#firstPage').bind("swiperight", function(){
            //alert("swiped right on the body element");
            $.mobile.changePage('#secondPage'); 

        });

现在我想将页面转换附加到此功能。如果它是在实际链接上,则可以应用data-transition,但由于此页面更改正在手动创建,因此我想知道如何向其附加转换。

我试过例如

    $('#firstPage').bind("swiperight", function(){
        //alert("swiped right on the body element");
        $.mobile.changePage('#secondPage','flip');  

    });

等但无济于事,任何想法我将如何生效? 谢谢你提前。

2 个答案:

答案 0 :(得分:1)

尝试将bind替换为on

$('#firstPage').on("swiperight", function(){
        //alert("swiped right on the body element");
        $.mobile.changePage('#secondPage','flip');  
 });

我遇到了类似的问题,这对我有用。

答案 1 :(得分:1)

你差不多了,你只需要在{}括号内声明函数的第二个参数(你的选项):

$('#firstPage').bind("swiperight", function(){

    //alert("swiped right on the body element");
    $.mobile.changePage( "#secondPage", { transition: "flip"} );

});