[英]Dynamically pick first screen for cordova application with Jquery Mobile
I am developing an application with cordova 3.50 and jquery mobile. 我正在使用cordova 3.50和jquery mobile开发应用程序。 I want to load the first page depending on whether the user is logged in or not.
我想根据用户是否登录来加载第一页。 This is the behavior i desire:
这是我想要的行为:
After the splash screen if the user is already logged in i want the home page to appear. 在启动屏幕之后,如果用户已经登录,我希望显示主页。
After the splash screen if the user is not logged in i want the login screen to appear 在启动屏幕之后,如果用户未登录,我希望出现登录屏幕
Is there anyway i can configure this (deciding which page to display) in JQM or using javascript/jQuery? 无论如何,我可以在JQM或使用javascript / jQuery进行配置(决定要显示哪个页面)吗?
yes it is possible 对的,这是可能的
$(document).ready(function(){
$.mobile.ajaxEnabled = false;
$("#start").on('pageinit', function() {
if(loggedin)
changePage("pages/home.html");
else
changePage("pages/login.html");
});
});
function changePage(page_id){
$.mobile.changePage(page_id, {transition: "flow", changeHash: false});
}
where #start is the id of the index.html, loaded as the first page of phonegap and loggedin is the var which holds boolean value 其中#start是index.html的ID,作为phonegap的第一页加载,而loginin是保存布尔值的var
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.