我是新的jQuery手機。我想使用jQuery Mobile的showPageLoadingMsg(),但它不工作。以下是我的代碼請任何人可以幫助我。
code
< !DOCTYPE html>
< html>
< head>
< meta charset="utf-8">
< meta name="viewport" content="width=device-width, initial-scale=1">
< title>Single page template</title>
< link rel="stylesheet" href="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.css" />
< script type="text/javascript" src="http://code.jquery.com/jquery-1.6.4.min.js"></script>
< script type="text/javascript" src="http://code.jquery.com/mobile/1.0/jquery.mobile-1.0.min.js"></script>
< /head>
< body>
< !-- BMR Screen page -->
< div data-role="page" id="BMR_screen">
< div data-role="header" data-theme="e" id="hdrBMRScreen">
< h1> BMR Screen< /h1>
< /div>
< div data-role="content" id="contentBMRScreen">
< div data-role="fieldcontain">
< label for="BMR_age">Age(in years):</label>
< input type="text" id="BMR_age" />
< /div>
< a href="#BMR_Result" onclick="BMR_Cal()" data-role="button">submit</a>
< /div>
< /div>
< !-- End BMR Screen -->
< div data-role="page" id="BMR_Result">
< div data-role="header" data-theme="b" >
< a data-role="button" data-rel="back" data-icon="back">back</a>
<h1>BMR Result</h1>
< /div>
< div data-role="content">
< p id="W_Range">Weight Range:</p>
< /div>
< /div>
< script type="text/javascript">
var agevar;
$(document).ready(function() {
// Initialize variables
ageVar = $('#BMR_age');
});
function BMR_Cal()
{
$.mobile.loadingMessage = "please wait...";
$.mobile.showPageLoadingMsg();
if(ageVar.val() > 0)
{
some code is there
.............
$.mobile.changePage($("#BMR_Result"), { transition: "flip"});
}
$.mobile.hidePageLoadingMsg();
}
< /script>
< /body>
< /html>
感謝
對不起,它不工作。 – naresh
嘗試setTimeout,因爲UPDATE在我的回答 – Leon
仍然沒有working.here我使用$(document).ready函數。這有什麼問題嗎?因爲我在一些使用$(document).bind(「mobileinit」,function(){//覆蓋這裏覆蓋這裏 })的地方看到了。 – naresh