ASP.NET MVC 4 jQuery Validation Script Bundle Not Working

随声附和 提交于 2019-12-02 15:35:33

The .live method has been deprecated in jQuery v1.7+ and removed in jQuery v1.9+.

Bugreport: http://bugs.jquery.com/ticket/13213
Explanation: http://jquery.com/upgrade-guide/1.9/#live-removed

.live() removed

The .live() method has been deprecated since jQuery 1.7 and has been removed in 1.9. We recommend upgrading code to use the .on() method instead. To exactly match $("a.foo").live("click", fn), for example, you can write $(document).on("click", "a.foo", fn). For more information, see the .on() documentation. In the meantime, the jQuery Migrate plugin can be used to restore the .live() functionality.

How to fix: Download the jquery migrate plugin and add it to your bundling:

  bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
              "~/Scripts/jquery-{version}.js",
              "~/Scripts/jquery-migrate-{version}.js"));

Update: The migrate plugin is now available from Nuget as well:

PM> Install-Package jQuery.Migrate

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