-
-
Save tcaddy/1879026 to your computer and use it in GitHub Desktop.
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 | |
); | |
} |
If the only reason you need underscore.js is to provide delay()
support then window.setTimeout(fn, delay);
will do the same as you don't have any extra parameters to pass
Is there anywhere a link to an adequate RoR example which uses this function?
Here is a link to see it in action: http://singapore.highpoint.edu/tix/login
You can simulate a bad login by entering '123' in the barcode field.
You will briefly see the familiar ajax busy dialog for jQuerymobile.
Then you will get an error message about a login failure -- the sort of message that is typical for flash[:notice].
The error message is the ajax busy dialog w/ an alternate message, alternate theme, and with the animated GIF hidden.
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
Note, for the flash[:notice] messages, I used theme 'e', which looks good for error messages.
Also, see my fork of jQuery Mobile which adds support for HTML markup in the loading message.