I have an issue with moving backwards through the history stack in my jquery mobile app.
Essentially, I have three pages:
The record pages are created dynamically based on a table and a record_id, appended to the document body each time a new record is selected.
var page_id = table + record_id;
var pg_html = newPageHTML(page_id );
$('body').append(pg_html);
$.mobile.changePage($("#" + page_id));
after advancing to a record and pressing the 'back' button (data-rel="back"), expected behavior would be to go back to the previous page, be it another record or the results list, but I am sent all the way back to search form. This occurs when i use data-dom-cache="true" and when I do not.
Any explanation as to why this would be? Thanks for the help.
Get the ID of the previous page in DOM then move to it.
Working Demo
$('.selector').on('click', function() {
// get the ID of the previous page
var previous = '#' + $.mobile.activePage.prev('div[data-role="page"]')[0].id;
// move to previous page with reverse effect
$.mobile.changePage(previous, {
transition: 'slide',
reverse: true
});
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With