m1crdy
m1crdy

Reputation: 1401

jQuery Mobile: Is there a way to do some js before the first page shows up?

I´m developing an app with jQuery Mobile and Phonegap where I need to check a variable before the first page shows up. It´s only 3 lines of code, where I check if a variable is true or false. If it´s true the user gets redirected to another page with mobile.changePage().

So is there a way to check this variable before the user gets to see the first page. (Must be executed between splashscreen disappears and first page shows up. Thx for your help

Upvotes: 1

Views: 131

Answers (2)

Omar
Omar

Reputation: 31732

You need to listen to pagebeforechange event and not pagebeforeshow. Because the first one fires before transition triggers and most importantly before updating browser's history.

  • pagebeforechange: Triggered twice during the page change cyle: First prior to any page loading or transition and next after page loading completes successfully, but before the browser history has been modified by the navigation process.

  • pagebeforeshow: Triggered on the "toPage" we are transitioning to, before the actual transition animation is kicked off.

Related post: https://stackoverflow.com/a/19522643/1771795

Demo

Upvotes: 1

Dom
Dom

Reputation: 2569

Take a look at JQM's pagebeforeshow event. Documentation is here.

Upvotes: 0

Related Questions