加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > asp.Net > 正文

asp.net-mvc – ajax链接被误处理

发布时间:2020-12-16 06:24:40 所属栏目:asp.Net 来源:网络整理
导读:我有一个带有 jquery-mobile app的asp.net mvc 4. 在一个页面(url:/ StatementBatch)上,我有一个批次列表,它们只是批次详细信息页面的链接(url:/ StetementBatch / Details / 4). li a href="/StatementBatch/Details/4" h3January 2012/h3 div style="flo
我有一个带有 jquery-mobile app的asp.net mvc 4.

在一个页面(url:/ StatementBatch)上,我有一个批次列表,它们只是批次详细信息页面的链接(url:/ StetementBatch / Details / 4).

<li>
    <a href="/StatementBatch/Details/4">
        <h3>January 2012</h3>

        <div style="float: right; width: 30%;"><strong>Issued  : </strong>1/10/2012 12:00:00 AM</div>
        <div style="float: right; width: 30%;">Completed</div>

        <p class="ui-li-aside"><strong>1277</strong></p>
    </a>


</li>

奇怪的是,一旦点击链接,并且细节页面呈现,浏览器当前网址现在是http:// localhost:49457 / StatementBatch#/ StatementBatch / Details / 4

我需要在应用中更改以修复此行为?

我的猜测是它的某种类似ajax加载相关的问题,但我的共享_Layout.cshtml文件包含$.mobile.ajaxEnabled = false;,我预计它会杀死所有ajax加载,但我显然错误地解释了那个.

谢谢!

解决方法

我怀疑这可能就是答案

jQuery Mobile ajaxEnabled doesn’t work?

将测试,看看我是否可以使它工作

将mobileinit绑定移动到jquery之后,但在jquery-mobile完成之前.这似乎是MVC4(新)移动Web应用程序模板中的一个错误,它只是简单地将所有脚本捆绑在一起

这失败了….

<link href="@System.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl("~/Content/css")" rel="stylesheet" type="text/css" />
<script src="@System.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl("~/Scripts/js")"></script>

<script>
    $(document).bind("mobileinit",function() {
        // As of Beta 2,jQuery Mobile's Ajax navigation does not work in all cases (e.g.,// when navigating from a mobile to a non-mobile page,or when clicking "back"
        // after a form post),hence disabling it.
        $.mobile.ajaxEnabled = false;
    });
</script>

但这有效….

<link href="@System.Web.Optimization.BundleTable.Bundles.ResolveBundleUrl("~/Content/css")" rel="stylesheet" type="text/css" />

<script src="../../Scripts/jquery-1.7.2.js" type="text/javascript"></script>
<script src="../../Scripts/jquery-ui-1.8.11.js" type="text/javascript"></script>

<script>
    $(document).bind("mobileinit",hence disabling it.
        $.mobile.ajaxEnabled = false;
    });
</script>

<script src="../../Scripts/jquery.mobile-1.1.0.js" type="text/javascript"></script>
<script src="../../Scripts/jquery.unobtrusive-ajax.js" type="text/javascript"></script>
<script src="../../Scripts/jquery.validate.js" type="text/javascript"></script>
<script src="../../Scripts/jquery.validate.unobtrusive.js" type="text/javascript"></script>
<script src="../../Scripts/modernizr-2.5.3.js" type="text/javascript"></script>

谢谢…

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读