pagebeforehide return 'undefined' for ui.nextPage #700

Closed
jstrimpel opened this Issue Dec 18, 2010 · 3 comments

Projects

None yet

4 participants

@jstrimpel

pagebeforehide and pagebeforeshow are returning undefined when referencing ui.prevPage and ui.nextPage. I have tried various different combinations since the documentation states that 'Note that all four of these events expose a reference to either the next page (nextPage) or previous page (prevPage), depending on whether the page is being shown or hidden', but nothing has worked thus far.

$('div').live('pagebeforehide',function(event, ui){
console.log(ui.nextPage.attr('id'));
});

@jeffv
jeffv commented Dec 23, 2010

I can confirm this issue. I tried all four events and they all behave erratically when exposing the references to nextPage/prevPage.

For example:
'pagebeforeshow': nextPage is always undefined. prevPage is only defined if there is no prevPage (giving an empty jquery object as expected).

'pagehide': prevPage is always undefined. nextPage appears as expected

'pagebeforehide': both prevPage and next page are always undefined.

'pageshow': nextPage always undefined, prevPage works as expected

@scottjehl
Contributor

So, these are more consistent now, but the idea is that you'd bind to the div that's being shown or hidden, so "this" refers to the target, and nextPage or prevPage gives you the other page involved in the transition.

$("div")
.live("pagebeforeshow pageshow",function(e,ui){
    console.log(e.type + " " + ui.prevPage );
}).live("pagebeforehide pagehide",function(e,ui){
    console.log(e.type + " " + ui.nextPage );
});

That said, the above tests out fine for me so I'm closing this as fixed. Let us know if you run into any issues given the explanation above and we'll be sure to document it better in the end.

@scottjehl scottjehl closed this Mar 23, 2011
@fcheslack fcheslack pushed a commit to fcheslack/jquery-mobile that referenced this issue Jul 28, 2011
Phil Barnes + Scott Jehl Pass null event param for page _trigger beforehide and beforeshow -- …
…Fixes issue #700
b740854
@sbudhram

Please update the documentation on this issue. The docs are still incorrectly stating that 'pagehide' event has the prevPage attribute. I had to search for a while to find this.

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