Publishers of technology books, eBooks, and videos for creative people

Home > Articles > Design > Voices That Matter

  • Print
  • + Share This
This chapter is from the book

This chapter is from the book

Customizing Loading Messages

When pages are loading, a default message appears if there’s a delay or if the page is not yet preloaded. The jQuery Mobile framework allows you to customize this message and a page-error loading message.

You can customize the loading message through the loadingMessage property. Set loadingMessage to any custom string by binding to the mobileinit event, which jQuery Mobile fires as soon as the document loads.

$(document).bind("mobileinit", function() {
    $.mobile.loadingMessage = 'Please wait';
});

This code will display a loading message that says “Please wait.” The default message used for page loading is “Loading.” The property can also be set to false to display no message at all:

$(document).bind("mobileinit", function() {
    $.mobile.loadingMessage = false;
});

When there is an error loading a page, jQuery Mobile displays a message that can also be customized through the API. The default message for page-load errors is “Error Loading Page.” You can set the pageLoadErrorMessage property to any custom string as the error message:

$(document).bind("mobileinit", function() {
    $.mobile.pageLoadErrorMessage = 'There was an error, please try again.';
});
  • + Share This
  • 🔖 Save To Your Account