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,