不要隐藏加载器,直到页面完全加载在jquery mobile中

Sau*_*hLP 5 jquery setinterval jquery-mobile jquery-mobile-loader

我试图显示页面加载小部件,直到页面完全加载,之后它应该隐藏...并且每次我打击任何锚点传输到下一页时执行此过程..

支持我有三页......

<div data-role="page" id="home">....</div>
<div data-role="page" id="about">....</div>
<div data-role="page" id="contact">....</div>
Run Code Online (Sandbox Code Playgroud)

我正在使用的脚本: -

$(document).on("pagecreate", function(event) { 
    //alert("Take It Show");
    $( ".ui-loader" ).loading( "hide" );
});
Run Code Online (Sandbox Code Playgroud)

是否可以添加转换像data-transition="slide"任何锚或data-ajax="false"在其中使用... ??

Gaj*_*res 9

工作示例:http://jsfiddle.net/Gajotres/Zr7Gf/

基本上,从底部开始的javascript就是你所需要的.

HTML:

<!DOCTYPE html>
<html>
<head>
    <title>jQM Complex Demo</title>
    <meta name="viewport" content="width=device-width; initial-scale=1.0; maximum-scale=1.0; minimum-scale=1.0; user-scalable=no; target-densityDpi=device-dpi"/>
    <link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css" />
    <script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>    
</head>
<body>
    <div data-role="page" id="index">
        <div data-theme="a" data-role="header">
            <h3>
                First Page
            </h3>
            <a href="#second" class="ui-btn-right">Next</a>
        </div>

        <div data-role="content">

        </div>

        <div data-theme="a" data-role="footer" data-position="fixed">

        </div>
    </div>    
    <div data-role="page" id="second">
        <div data-theme="a" data-role="header">
            <h3>
                First Page
            </h3>
            <a href="#index" class="ui-btn-left">Back</a>
        </div>

        <div data-role="content">

        </div>

        <div data-theme="a" data-role="footer" data-position="fixed">

        </div>
    </div>     
</body>
</html>   
Run Code Online (Sandbox Code Playgroud)

Javascript:

$(document).on('pagebeforecreate', '[data-role="page"]', function(){     
    var interval = setInterval(function(){
        $.mobile.loading('show');
        clearInterval(interval);
    },1);    
});

$(document).on('pageshow', '[data-role="page"]', function(){  
    var interval = setInterval(function(){
        $.mobile.loading('hide');
        clearInterval(interval);
    },300);      
});
Run Code Online (Sandbox Code Playgroud)