问题
Am using JQuery mobile for a usermenu list, but it seems to save the pressed button link "ui-state=dialog" Which is disturbing the navigation when am using the back button on the webbrowser. How can i remove the "ui-state=dialog" which adds to the URL?
Example: http://demos.jquerymobile.com/1.4.5/popup/
Try the first so called "basic popup", the saved URL which is: "ui-state=dialog" still appears in the broswer history.
回答1:
To resolve the refresh problem, I use to intercept #&ui-state and similar on page creation and eventually redirect to a clean url:
$(document).on("pagebeforecreate",function(){
if(window.location.hash!=""){
window.location.replace(window.location.origin+window.location.pathname);
}
});
To avoid to insert the #&ui-state in browser history, it's possible to add data-history="false" to every popup:
<div data-history="false" data-role="popup" ...
回答2:
I solved the problem: by using:
$( ".selector" ).popup({
history: false
});
$(document).on("pageinit", function()
{
$( ".selector" ).popup({
history: false
});
});
More information:
http://api.jquerymobile.com/popup/#option-history
回答3:
Another solution is by assigning data-history="false"
attribute in the markup:
<div data-history="false" data-role="popup" id="popup-1" data-theme="b" data-overlay-theme="b">
来源:https://stackoverflow.com/questions/41142990/jquery-mobile-ui-state-dialog