jQuery mobile不添加后退按钮?

时间:2013-05-02 14:59:37

标签: javascript jquery mobile-application jquery-mobile

我的头:

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <title></title>
    <script src="<?php echo base_url();?>/assets/js/vendor/modernizr-2.6.2.min.js"></script>
    <meta name='viewport' content='width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0 target-densitydpi=medium-dpi'/>
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.css" />

    <!--jQuery, mobile options, JQM-->
    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
    <script>window.jQuery || document.write('<script src="<?php echo base_url();?>assets/js/vendor/jquery-1.9.1.min.js"><\/script>')</script>
    <script src="<?php echo base_url();?>assets/js/transition.js"></script>
    <script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script>

    <script src="http://ricostacruz.com/jquery.transit/jquery.transit.min.js"></script>
    <link rel="stylesheet" href="<?php echo base_url();?>/assets/css/normalize.css">
    <link rel="stylesheet" href="<?php echo base_url();?>/assets/css/main.css">
</head>

transition.js:

$(document).bind("mobileinit", function() { 

    //back button
    $.mobile.page.prototype.addBackBtn = true;
    if (navigator.userAgent.indexOf("Android") != -1) { $.mobile.defaultPageTransition = 'none'; $.mobile.defaultDialogTransition = 'none'; } else {
        $.mobile.defaultPageTransition = 'pop';
    } 
});

为什么不添加?

1 个答案:

答案 0 :(得分:0)

确保此片段是在jQuery库加载之后,但是在加载jQueryMobile库之前:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script type="text/javascript">
$(document).bind("mobileinit", function() { 

    //back button
    $.mobile.page.prototype.options.addBackBtn = true;
    if (navigator.userAgent.indexOf("Android") != -1) { $.mobile.defaultPageTransition = 'none'; $.mobile.defaultDialogTransition = 'none'; } else {
        $.mobile.defaultPageTransition = 'pop';
    } 
});
</script>
<script src="http://code.jquery.com/mobile/1.3.1/jquery.mobile-1.3.1.min.js"></script>

请参阅:jquery-mobile still "No Back Button" (Beta 2)