Using jQuery mobile 1.3.2, I have a PhoneGap application in which I would like to update an initial login screen to reflect a data theme, based on the state of the application. login page html is:
login html:
<div id="login" data-role="page">
<div data-role="header">
<h1>Survey login</h1>
</div>
<div data-role="content">
<!--div id="logincontent"></div-->
<form id="form-login">
<div data-role="fieldcontain" class="ui-hide-label">
<label for="login-password">Password:</label>
<input type="password" name="login-password" id="login-password" value="" placeholder="Password" />
</div>
<a href="#" id="login-button" data-role="button" onclick="checkLogin()">Login</a>
</form>
</div>
<div data-role="footer" id="login-footer" data-theme="a">
<h4 id="login-footer-header">UIC & EVL</h4>
</div>
</div>
JS function to change theme of login page:
function displayAppStatus(type){
if(type == 'suspend'){
$("#login").page({theme:'g'});
$("#login").trigger('create');
$("#login-footer-header").text("Log in to break suspension");
}
else if(type == 'bedtime'){
$("#login").page({theme:'f'});
$("#login").trigger('create');
$("#login-footer-header").text("Log in to break bedtime");
}
else if(type == 'delay'){
$("#login").page({theme:'h'});
$("#login").trigger('create');
$("#login-footer-header").text("Log in to break delayed notification");
}
//Cancel appStatus display
else if(type == 'cancel'){
$("#login").page({theme:'a'});
$("#login").trigger('create');
$("#login-footer-header").text("UIC & EVL");
}
}
linked stylesheets & scripts (just in case):
<link rel="stylesheet" href="css/main.css" />
<link rel="stylesheet" href="css/themes/ecig/ecig_themes.css" />
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.3.2/jquery.mobile.structure-1.3.2.css" />
<script src="cordova.js"></script>
<script src="js/jquery-1.10.2.js"></script>
<script src="js/jquery.mobile-1.3.2.js"></script>
And I call displayAppStatus throughout my code, if a user delays a notification, or suspends any notifications, or puts the app to sleep.
What happens is that I will see the login page flash the color of the correct data-theme, but then the theme for the page will switch back to the default quickly.
I have been here: Changing JQuery Mobile data-theme dynamically and jQuery mobile dynamically added theme to page
but neither of these threads have solved my problem.