Skip to content

Instantly share code, notes, and snippets.

@tcaddy
Created February 21, 2012 21:20
Show Gist options
  • Save tcaddy/1879026 to your computer and use it in GitHub Desktop.
Save tcaddy/1879026 to your computer and use it in GitHub Desktop.
Use jQuery Mobile $.mobile.showPageLoadingMsg() for other messages/notifications
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
);
}
@heschreib
Copy link

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment