I'm trying to bind to pagechange which is failing to work. Given the following basic page, how do I tell when page 2 is displayed?
<div data-role="page" id='page1'>
<div data-role="content">
<h3>Page 1</h3>
<a href="#page2"
data-role="button" data-transition="slide" data-inline="true"
>Open Page 2</a>
</div>
</div>
<div data-role="page" id='page2'>
<div data-role="content">
<h3>Page 2</h3>
<a href="#page1"
data-role="button" data-icon="arrow-l" data-rel="back" data-inline="true"
>Back to page 1</a>
</div>
</div>
JavaScript
$("#page2").bind("pageshow", function(toPage, ui) {
console.log($(this));
console.log(toPage);
});
The change event never fires, though if I use $(document)
then it fires, but both $(this)
and toPage
I wish to know when page2 is first presented so I can perform functions to retrieve remote data.