Reputation: 105
<script>
$(document).on('pageinit', '#page03' ,function(){
drawTimeLine(3);
});
</script>
I'm developing an app in jQuery Mobile and I'm pretty new to it.
I am using a multipage html and I want when the page who's id is "page04" loaded, to drawTimeLine(value)
with a value=4 and when the page with id "page03" to the value for the drawTimeLine(value)
to be 3 and so on…
I've tried for more than a week and still haven't succeeded.
If I understood correctly from the JQM api – I should use pagecontainerbeforeload
in some way.
If some more code is needed, please tell me and I'll reupload.
Upvotes: 2
Views: 85
Reputation: 57309
Working example: http://jsfiddle.net/Gajotres/vds2U/
$(document).on('pagecontainershow', function () {
pageId = $('body').pagecontainer('getActivePage').prop('id');
if (pageId === 'index') {
alert('Page index');
}
if (pageId === 'second') {
alert('Page second');
}
});
pagecontainershow will trigger when every page is ready to be shown. Then you need to get page ID and do something during each page execution. Of course there are other page events but you need this one if you want to draw something.
This code used to be easier but latest page handling widget changed things a lot.
Upvotes: 2