我试图显示页面加载小部件,直到页面完全加载,之后它应该隐藏…并且每次我打击任何锚点传输到下一页时执行此过程..
支持我有三页……
<div data-role="page" id="home">....</div> <div data-role="page" id="about">....</div> <div data-role="page" id="contact">....</div>
我正在使用的脚本: –
$(document).on("pagecreate",function(event) { //alert("Take It Show"); $( ".ui-loader" ).loading( "hide" ); });
是否有可能将data-transition =“slide”等转换添加到任何锚点或使用data-ajax =“false”…
解决方法
工作示例:
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>
Javascript:
$(document).on('pagebeforecreate','[data-role="page"]',function(){ var interval = setInterval(function(){ $.mobile.loading('show'); clearInterval(interval); },1); }); $(document).on('pageshow',function(){ var interval = setInterval(function(){ $.mobile.loading('hide'); clearInterval(interval); },300); });