Freigeben über


jQuery-validate in MVC

Boy, is debugging in a strongly typed language easier than in JavaScript.

I’m really glad to have NuGet in Visual Studio. Of course, I immediately ran “Update-Package jQuery”, and then merrily went along until I later discovered that my login and registration pages weren’t working anymore.  The IE9 and Visual Studio debuggers were kind enough to give me this error in jquery.validate.unobtrusive.min.js:

Line: 5
Error: Unable to set value of the property 'unobtrusive': object is null or undefined

I could see there was a variable named “d” with an property named “unobtrusive”, but the value of “d” was unknown in the debugger.

Of course I went down a couple of false paths, and tried to enable client-side verification and unobtrusive JavaScript in web.config.  I finally found a StackOverflow post stating that the latest version of jquery-validate isn’t working on several versions of Internet Explorer.  I can’t say I’ve given that deep testing, but it seems plausible.

I don’t know how much searching through code I would have done without finding a workaround or fix.

I rolled back to jquery-1.5.1, and everything was fine.

It is nice to know that there’s a version flag in NuGet’s Install-Package, so that you can pick legacy versions of packages for these situations.

 PM> Install-Package jQuery -version 1.5.1
Successfully installed 'jQuery 1.5.1'.
OrderManagementWeb already has a reference to 'jQuery 1.5.1'.
  

Technorati Tags: IE9,NuGet,Visual Studio,Internet Explorer,jQuery

Windows Live Tags: IE9,NuGet,Visual Studio,Internet Explorer,jQuery

  

Comments

  • Anonymous
    December 01, 2011
    I'm getting the same error with 1.5.1 and 1.7 A work around for develpment is to use the non minified versions.

  • Anonymous
    May 10, 2012
    v1.9 still seems to have the problem, and I'm getting it with the non-minified version as well.

  • Anonymous
    February 24, 2013
    I get the same error with Jquery-1.9.1.js. Any ideas how to solve this issue?