Created
February 21, 2012 21:20
-
-
Save tcaddy/1879026 to your computer and use it in GitHub Desktop.
Use jQuery Mobile $.mobile.showPageLoadingMsg() for other messages/notifications
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var default_msg = $.mobile.loadingMessage; // set this outside function scope so we can access it later | |
// you must provide a msg argument. The delay and theme arguments are optional. | |
function show_hide_message = function(msg,delay,theme) { | |
if (typeof(delay)==='undefined') { | |
var delay = 3500; // in milliseconds | |
} | |
if (typeof(theme)==='undefined') { | |
var theme = 'a'; // default theme; setting this to 'e' is nice for error messages | |
} | |
var css_class = ''; | |
if (theme==='e') { | |
css_class = 'ui-body-e'; | |
} | |
$.mobile.loadingMessage = msg; | |
$.mobile.showPageLoadingMsg(); | |
$(".ui-loader").addClass(css_class).find(".spin:visible").hide(); // hide the spinner graphic | |
setTimeout( | |
function() { | |
$(".ui-loader").removeClass(css_class).find(".spin:hidden").show(); // show the spinner graphic when we are done | |
$.mobile.hidePageLoadingMsg(); | |
$.mobile.loadingMessage = default_msg; // reset back to default message | |
}, | |
delay | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi tcaddy,
I'm a little bit a rails newbie ...
Can you please provide a rails code snippet to call or include thesample above js function in my controller or view. thx