i am trying to show the page loading widget till the page loads completely, after that it should hide... and do this process every time i punch any anchor to transmit into next page..

Support i have three pages...

<div data-role="page" id="home">....</div>
<div data-role="page" id="about">....</div>
<div data-role="page" id="contact">....</div>

Script on this i am using:-

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

Is it possible to add transition like data-transition="slide" to the any anchor or use data-ajax="false" in it...??

有帮助吗?

解决方案

Working example: http://jsfiddle.net/Gajotres/Zr7Gf/

Basically javascript from the bottom is all you need.

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>   

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);      
});
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top