Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Closed
nisc opened this Issue · 4 comments

4 participants

@nisc

$.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.

lifecycle

@adammessinger

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

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

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

@gabrielschulhof
Collaborator

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
Something went wrong with that request. Please try again.