ASP.NET MVC 4:不能修改jQuery的不显眼的Ajax [英] ASP.NET MVC 4: cannot modify jQuery Unobtrusive Ajax
问题描述
使用 ASP.NET MVC 4
和的NuGet
来管理软件包。
升级到的jQuery 1.9.1
通过的NuGet
之后,我开始越来越的JavaScript
关于去除误差生活()
在的jQuery 1.9.x的
功能。
After upgrading to jQuery 1.9.1
via NuGet
, I began getting JavaScript
errors regarding the removal of the live()
function in jQuery 1.9.x
.
我按F5从VS.NET调试模式下运行,进入登录页面,并获得以下内容:
I hit F5 to run in debugging mode from VS.NET, go to the login page, and get the following:
发现这个StackOverflow的答案: http://stackoverflow.com/a/14512797 并取得了4修改〜\\脚本\\ jquery.unobtrusive-ajax.js
。
Found this StackOverflow answer: http://stackoverflow.com/a/14512797 and made the 4 changes to ~\Scripts\jquery.unobtrusive-ajax.js
.
我的 〜\\脚本\\ jquery.unobtrusive-ajax.js
My ~\Scripts\jquery.unobtrusive-ajax.js
:
$(document).on("click", "a[data-ajax=true]", function (evt) {
...
});
$(document).on("click", "form[data-ajax=true] input[type=image]", function (evt) {
...
});
$(document).on("click", "form[data-ajax=true] :submit", function (evt) {
...
});
$(document).on("submit", "form[data-ajax=true]", function (evt) {
...
});
我也物理删除 jquery.unobtrusive-ajax.min.js
并使用 WebGrease 1.3.0
从再生是我更新的 〜\\脚本\\ jquery.unobtrusive-ajax.js
I also physically deleted jquery.unobtrusive-ajax.min.js
and used WebGrease 1.3.0
to regenerate it from my updated ~\Scripts\jquery.unobtrusive-ajax.js
.
然而,出于某种原因,我的变化不使用 .live()
功能未生效。我试图停止IIS防爆preSS 8.0网站(本地主机:63798)下VS.NET运行MVC应用程序。
However, for some reason, my changes to not use the .live()
function are not sticking. I tried stopping the IIS Express 8.0 Web Site (localhost:63798) under which VS.NET is running the MVC App.
也试过做一个建设 - >清理解决方案,建设 - >按F5在调试模式下再次运行前重新生成解决方案。
Also tried doing a Build->Clean Solution, Build->Rebuild Solution before hitting F5 to run in debug mode again.
如果任何人有经历过这一点,并有任何见解,我将非常感激。先谢谢你。
If anyone has experienced this before and has any insight, I would be very grateful. Thank you in advance.
推荐答案
不显眼的jQuery阿贾克斯包已被固定在2.0.30116.0版本来解决这个问题。到 .live()调用
改为使用。对()
。
The Microsoft jQuery Unobtrusive Ajax package has been fixed in version 2.0.30116.0 to fix this problem. The calls to .live()
were changed to use .on()
.
请尝试升级您的NuGet包来获取最新版本。
Try upgrading your NuGet package to get the latest version.
不过,要使用jQuery的迁移包的建议是一个很好的发现在其他插件或不与jQuery的1.9变化兼容问题,你自己的code +。
However, the suggestion to use the jQuery Migrate package is a good one to find issues in other plugins or your own code that aren't compatible with the changes in jQuery 1.9+.
这篇关于ASP.NET MVC 4:不能修改jQuery的不显眼的Ajax的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!