Jquery mobile. Loading message on page change

3.6k Views Asked by At

I'm building offline application with Phonegap + JQM. Is there any possibility to set globally that on every page change event would showing loading message?

2

There are 2 best solutions below

1
Nirmal Patel On
$(document).live('pagebeforehide', function(){
    $.mobile.showPageLoadingMsg();
    //More stuff to do
});

$(document).live('pageshow', function(){
    //More stuff to do
    $.mobile.hidePageLoadingMsg();
});
0
Peter Ajtai On

Nirmal's answer doesn't work for me, but binding to the individual pages does:

$("div[data-role='page']").live('pagebeforehide', function(){
    console.log("showing....");
    $.mobile.showPageLoadingMsg();
    //More stuff to do
});

$("div[data-role='page']").live('pageshow', function(){
    //More stuff to do
    console.log("hiding....");
    $.mobile.hidePageLoadingMsg();
});

jsFiddle - look at the logs, sometimes it's too fast to see