I'm trying to disable my url from changing without disabling ajax in jquery mobile

 ̄綄美尐妖づ 提交于 2019-12-13 04:30:50

问题


When I navigate to a different page in my project in IE (and sometimes chrome) the new URL is added to the old one.

For example, if this is my original URL: localhost:49866/Home/Index

and I was to navigate to a different page, that URL is added to the old one like this:

localhost:49866/Home/Index#/Newpage

I've found that this is an ajax thing which makes it easier to retrieve old pages. However, is there a way to fix this without disabling my ajax?

The only solution I've found is to disable my ajax completely using this script:

$(document).ready(function () {
  if ($.browser.msie || $.browser.webkit) {

    $("a").attr("data-ajax", "false");
    $("a").attr("rel", "external");

    var a = $("form");
    if (a != null) {
        $("form").first().attr("data-ajax", "false");
        $("form").first().attr("rel", "external");
    }
  }
});

回答1:


You can set any url you want on each of your jquery-mobile pages. Use the data-url attribute on your data-role="page" div like this:

<div id='myJQMPage' data-role="page" data-url="/the/url/i/want")>
</div>


来源:https://stackoverflow.com/questions/18018967/im-trying-to-disable-my-url-from-changing-without-disabling-ajax-in-jquery-mobi

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