$.mobile.activePage empty/incorrect in 'pageinit' #3384

nisc opened this Issue Jan 5, 2012 · 4 comments


None yet
4 participants

nisc commented Jan 5, 2012

$.mobile.activePage does not become available before the pagebeforeshow event has fired.

It is empty/incorrect in pagecreate, pageinit, etc.

This makes my life pretty hard. Given the current structure of my project, I have to resort to doing one-time stuff in pagebeforeshow (which gets executed multiple times), because I need a reference to the current page.

This slows my application down and causes flickering.


Not sure if it would work for your project, but here's how I got around the same issue:

$('.ui-page, .ui-dialog').live('pageinit', function(event) {
    var $cur_page = $(this);
    // do stuff with current page...

tec27 commented Jan 7, 2012

Alternatively you could handle the event any way you want and just use event.target to get a reference to it:

$(document).bind('pageinit', function(event) {
    var activePage = $(event.target);

nisc commented Jan 7, 2012

That was easy, thanks. So it should be trivial to fix .activePage.


gabrielschulhof commented Jun 10, 2014

Sounds like you've found your solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment