Reputation: 424
I have a project with PhoneGap and jQueryMobile, using a multi-page template. On the home page the pageshow
, pageinit
, pagecreate
, pagebeforeshow
events don't fire. I have tried a couple of possible solutions.
Solution 1:
$('#home').on("pageshow", function(e) { ... }
With this solution, when I change to the second page and return to the home page, the event fires, but not the first time the application loads.
Solution 2:
var selector = ':jqmData(role=page)';
$('body').on("pageshow", selector,function(e) { ... }
I got Solution 2 from here, but it doesn't work for me.
How can I resolve this issue?
Upvotes: 1
Views: 753
Reputation: 424
Finally I found the solution to this, is create another page first and this redirect to home page with $.mobile.changePage('#home',{transition:'none'}), this page make all the init functions.
With this the home page fire all the events.
Upvotes: 1
Reputation: 5920
pagebeforeshow
, pageshow
, and other collections are empty when the first page is transitioned in during the application startup.
Note that this collection is empty when the first page is transitioned in during application startup.
Read up on the docs: http://jquerymobile.com/test/docs/api/events.html
Upvotes: 0