The code below is used to close active panel
when navigating backwards in history (browser's back button,
data-rel="back", $.mobile.back(), etc.) and cancels
navigation. The code works as it should except for one issue that it
clears "forward" history.
var newUrl;
$(window).on("hashchange",
function (e) {
newUrl =
e.originalEvent.newURL;
}).on("popstate",
function (e) {
var direction =
e.historyState.direction == "back" ? true :
false,
As most of you know, page events such as pageshow, beforeshow, hide and beforehide are now deprecated and will be removed in 1.5. In my humble opinion, replacing those events with pagecontainershow and hide is a draw back on JQM development. It is not possible to bind new events to specific pages, so we are ought to use if statement to check toPage object. What about dynamically created pages, with dynamic ID? I hope you reconsider removing page events. Thanks! Ps. I have reported an issue in this regard:
https://github.com/jquery/jquery-mobile/issues/6865