Want to show a dialog message in jQuery mobile when it is loaded
In jQuery mobile, I want to show a dialog message on my home page ( index.html
) when this page is first loaded. However, if a user navigates to different pages on my site and returns to mine index.html
, I don't want to show the dialog.
I am thinking about using a method pageshow
or pagebeforeshow
and checking an object prevPage
. Is there any other good way to do this?
source to share
Use the pageinit event , it will only fire once. It couldn't be easier than this.
JsFiddle example: http://jsfiddle.net/Gajotres/e9RcT/
$(document).on('pageinit', '#index', function(){
alert('This event will trigger only once!');
});
To check this, go to the second page and then return.
source to share