Jquery mobile: ui-state=dialog

不羁岁月 提交于 2021-02-10 05:31:08

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!