gpt4 book ai didi

jquery-mobile - 部分脚本未在 ASP.net MVC4 razor 中呈现

转载 作者:行者123 更新时间:2023-12-04 02:25:22 25 4
gpt4 key购买 nike

我正在使用 VSRC 在 ASP.net MVC4 razor 中开发 JQuery 移动应用程序,在 cshtml 页面部分脚本编写如下。

@section Scripts
{
<script type="text/javascript">
$(document).ready(function () {
jQuery("#register-form").validationEngine();
});
</script>
}

在 layout.cshtml 我有...
"@RenderSection("Scripts", false)".

它适用于初始页面(首先呈现的页面),但是当它通过“ActionLink”链接到其他页面时,在这些页面中编写的部分脚本不起作用。

有什么想法吗?

请帮忙,谢谢。

最佳答案

我有同样的问题。为了解决这个问题,我只是避免使用“脚本”部分。

删除 @section Scripts{从每个页面并将您的 js 代码放在页面的末尾。

对于您的示例,请确保移动 @Scripts.Render("~/bundles/jquery", "~/bundles/jquerymobile")到前线</head>在 _Layout.cshtml 中。这将保证 jquery 在到达 $(document).ready(function () {... 时被加载。

================================================

关于它发生的原因和其他解决方案的解释。 http://lextell.com/blog/2012/10/23/script-section-is-not-rendered-in-asp-net-mvc-4-jquery-mobile-when-navigate-to-another-page-2/

关于jquery-mobile - 部分脚本未在 ASP.net MVC4 razor 中呈现,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12740832/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com