$ .mobile.changePage $ .mobile.loading动画
问题描述:
我在这个问题上苦苦挣扎了一段时间。我的目的是向用户显示转轮,而$ .mobile.changePage方法将他重定向到另一个页面。然而,我找到的解决方案都不适合我。它必须是changePage方法的一些问题,杀死加载动画,因为当我放弃changePage方法,然后旋转轮显示。谢谢你的帮助。
这里是我的代码片段:
<!DOCTYPE HTML>
<head>
<script type="text/javascript" charset="utf-8" src="cordova-2.5.0.js"></script>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.css" />
<script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>
<script type="text/javascript">
$(document).bind('mobileinit', function(){
$.mobile.loader.prototype.options.text = "loading";
$.mobile.loader.prototype.options.textVisible = false;
$.mobile.loader.prototype.options.theme = "a";
$.mobile.loader.prototype.options.html = "";
});
</script>
<script src="http://code.jquery.com/mobile/1.3.0/jquery.mobile-1.3.0.min.js"></script>
</head>
<body onload="onBodyLoad();">
<!-- LOGIN PAGE -->
<div data-role="page" id="login_page">
<div data-role="content" id="login_content">
<div id="buttons">
<button value="Login" id="login">Login</button>
<button value="Logout" id="logout">Logout</button>
</div>
</div>
</div>
<!-- TIMELINE PAGE -->
<div data-role="page" id="timeline_page">
<div data-role="header" id="timeline_head" data-nobackbtn="true">
<h1>BlueBirdGap</h1>
<h2>Timeline</h2>
<a id="timeline_button_back" data-icon="arrow-l" class="ui-btn-left"
href="javascript:return true;" data-role="button" data-inline="true">Zpět</a>
<div data-role="controlgroup" class="ui-btn-right">
<a id="logout_button" data-icon="delete" data-role="button">Logout</a>
<a id="new_tweet_button" data-icon="plus" data-role="button" data-theme="b">Tweet</a>
<hr>
</div>
</div>
<div data-role="content" id="timeline_content">
<div id="new_tweet_area">
<textarea id="tweet_text"></textarea>
<button data-role="button" data-icon="plus" data-theme="b" class="ui-btn-right" onclick="Twitter.post()">Post</button>
</div>
<div id="home_timeline"></div>
</div>
<div data-role="footer" id="timeline_footer"></div>
</div>
<script>
function onBodyLoad() {
document.addEventListener("deviceready", onDeviceReady, false);
}
function onDeviceReady() {
cb = window.plugins.childBrowser;
$('html').addClass("ui-loading");
if(localStorage.getItem(twitterKey)){
showLogin(1);
$.mobile.loading('show');
Twitter.timeline();
$.mobile.changePage('#timeline_page', {transition: "slide"});
$.mobile.loading('hide');
}
}
</script>
我要补充一点,我正在使用的PhoneGap框架和JQM 1.3.0 Android应用程序。
答
使用$.mobile.showPageLoadingMsg();
和$.mobile.hidePageLoadingMsg();
而不是$.mobile.loading();
。
但是,如果他们不工作,使用下面的代码。
显示加载微调器。
$('div.ui-loader').show();
隐藏它。
$('div.ui-loader').hide();
加载微调器隐藏在</body>
之前的div中,如下所示。所有你需要的是show();
它或hide();
它。
<div class="ui-loader ui-corner-all ui-body-a ui-loader-default" style="display: block;">
<span class="ui-icon ui-icon-loading">
</span>
<h1>loading</h1>
</div>
'$ .mobile.showPageLoadingMsg()'折旧。你不应该使用它。 – 2013-03-28 04:04:35
感谢@MayuMayooresan提示;) – Omar 2013-03-28 07:13:31
Mayu是正确的。然而,这些方法仍然存在,并推迟对优先方法的调用:$ .mobile.loading然后调用'loaderWidget'。该小部件仅在'pagecontainerCreate'事件触发后才存在。 (参见JQM 1.3.1,行:1115-1117) 更多细节:[jqmDoco](http://jquerymobile.com/demos/1.2.0/docs/pages/loader.html) – 2013-06-04 01:38:33