RaveN
RaveN

Reputation: 115

jQuery Mobile: Programmatically show ajax loader

I load content with an ajax request and it can take some time till everything (images and text) is loaded and displayed on the page.

I would like to show a loading spinner at the start of the ajax call and hide it when all content is really there.

It tried sth like this, but it doesn't work:

$(this).ajaxStart(function() {
 $.mobile.loading('show');
});

$(this).ajaxStop(function() {
 $.mobile.loading('hide');
});

Update:

The loader is spinning now, but I still need an event when all content is finally rendered by the browser

Upvotes: 2

Views: 2240

Answers (1)

Gajotres
Gajotres

Reputation: 57309

Or you can add this into a ajax call:

beforeSend: function() {
    $.mobile.showPageLoadingMsg(true);
},
complete: function() {
    $.mobile.hidePageLoadingMsg();
}

Upvotes: 3

Related Questions