ASP.NET MVC 4 jQuery Validation Script Bundle Not Working

前端 未结 1 1480
栀梦
栀梦 2021-01-30 17:24

I have recentely upgraded a website to use ASP.NET MVC 4 and have the following code to render my jQuery validation bundle.

But I get the following error:



        
相关标签:
1条回答
  • 2021-01-30 18:15

    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

    0 讨论(0)
提交回复
热议问题