Prior to JQM 1.4, I created dialogues using data-role="dialog"
and those pages were not added to the back stack, so navigating off one and then pressing back would bring you to the page before the dialog.
Now with 1.4.5, dialogues are defined as data-role="page"
with data-dialog="true"
. Using this method, the dialog is added to the back stack, so if I navigate off the dialog and then tap back I am returned to the dialog. This is not the behavior I want. Is there a way, when the dialog opens, to tell JQM NOT to add it to the back stack?
Updated
As of jQuery Mobile 1.4, dialog widget is deprecated and will be removed in 1.5. It is now converted into a page - as you've mentioned - with
data-dialog="true"
.When you navigate to a dialog, jQM updates framework's navigation history as well as browser's navigation history. Even if you navigate to a dialog programmatically with
changeHash
disabled, when you hit back button, you will redirected to second previous history record.A work around is to listen to
pagecontainerbeforechange
and altertoPage
to navigate to the page where the dialog was called.When you want to alter
toPage
, it should be astring
and not anobject
. The event fires twice on each navigation, it returnsstring
first and then anobject
.When it returns a
string
, check navigation directionoptions.direction
. If the direction isback
, loop through$.mobile.navigate.history.stack
in reversed order. The previous record should not be a dialogui-dialog
nor the active pageui-page-active
. If both conditions return true, altertoPage
.