Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Child dialog opened from parent dialog closes with reverse transition of parent dialog #4951
Jsbin seems to be having issues at the moment so I can't create a sample to demonstrate the issue.
This only happens with the close button that is automatically added during enhancement. I don't mean to go on a tangent, but that brings up another thing that might be an issue. If I manually add an <a> element to the markup of the dialog page that serves as the close button, the close button that gets automatically added during enhancement should not get added at all. Currently in 1.2 beta, if I have my own <a> element with all the attributes it needs and a class of ui-btn-right, then there will also be one on the left that is automatically added. If I have my own <a> element with a class of ui-btn-left, then there will end up being two close buttons on the left because of the one that gets automatically added over top of it.
Anyway, back to the issue "Child dialog opened from parent dialog closes with reverse transition of parent dialog."
The culprit seems to be the hashchange listener that's triggered as a result of a call to window.history.back() in the close function of the https://github.com/jquery/jquery-mobile/blob/master/js/widgets/dialog.js.
For reference, here are lines 43-51 of https://github.com/jquery/jquery-mobile/blob/master/js/widgets/dialog.js
The call to self.close() results in lines 90-92 of the same file being executed when hashListeningEnabled equals true
For whatever reason, that causes the child dialog to close with the reverse of the transition that was used to open the parent dialog rather than using the reverse of the transition that was used to open the child.
If I override $.mobile.hashListeningEnabled = false, then the issue goes away. Similarly, if I add a data-rel='back' to the headerCloseBtn markup on line 21 of of https://github.com/jquery/jquery-mobile/blob/master/js/widgets/dialog.js file, then the issue also goes away. But, apparently the data-rel='back' attribute was removed in exchange for using an anonymous function (which calls self.close()) so that "select menu dialogs can replace the close method." The comment goes on to say "This is a change from previously just defining data-rel=back on the button and letting nav handle it."