在jquery mobile 1.4.1中更改defaultPageTransition?

时间:2014-10-10 07:02:12

标签: javascript jquery jquery-mobile

我想知道如何将jquery移动默认页面转换更改为幻灯片?

我试过

$("div[data-role=page]").bind("pagebeforeshow", function ( e , data ) {
    console.log("++++++++++++++++++++++++++++++++++++ page before show");
    $.mobile.silentScroll(0);
    $.mobile.changePage.defaults.transition='slide';

});

$( document ).on( "mobileinit", function() {
  //apply overrides here
  $("div[data-role=page]").pagecontainer( "change" , { transition: "slide" } );
});

但两者都不起作用

3 个答案:

答案 0 :(得分:2)

解决方案: 好的,找到了这个mobileinit在jq移动加载之前需要调用的答案

<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
            <script type="text/javascript">
                $( document ).on( "mobileinit", function() {
                    alert("yes");
                    console.log("mobile initialize .....");
                  $.extend( $.mobile , {
                    defaultPageTransition: 'slide'
                  });
                });


            </script>
<script src="http://code.jquery.com/mobile/1.4.4/jquery.mobile-1.4.4.min.js"></script>

答案 1 :(得分:1)

像这样:

$( document ).on( "mobileinit", function() {
  $.extend( $.mobile , {
    defaultPageTransition: 'slide'
  });
});

答案 2 :(得分:0)

或者这个:

$(document).bind('mobileinit', function() {
    $.mobile.defaultPageTransition = "slide";
});