Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ASP.NET MVC Best Practice for jQuery updates [closed]

History

I created a new ASP.NET MVC 4.0 project that was basic and didn't include jQuery or other scripts that the Intranet and Internet templates insert by default. I then went to add the scripts using NuGet and installed the latest version of all the jQuery and related files that are normally installed by the MVC Intranet and Internet templates.

When I tried running the application I started to receive errors. Apparently there are incompatibilities with the libraries/extensions that were written previous to jQuery 1.9. It seemed like after fixing an issue I'd run into another. I finally gave up and copied the versions of the js files that would have installed. This resolved the issues I was able to use features such as remote validation.

Questions

Since I'm new to ASP.MVC, I'd like to know what the Best Practice is related to jQuery updates. I assume I need to wait until all the libraries/extensions have caught up, but I would need to follow the status of each library/extension to determine when I could upgrade.

  1. Is it simply better to wait and just use the versions that are installed with the MVC templates and not upgrade? And when the next update for MVC comes out, then copy those libraries/extensions into the scripts folder that the updated templates use?
  2. I noticed that the MVC templates do not install the jQuery NuGet packages but install files to the Content and Script folders. Is this to prevent developers from upgrading and experiencing the issues I found with using newer version of the libraries/extensions?
  3. Does Microsoft time updates to jquery.unobtrusive-ajax.js and related libraries to updates to ASP.NET MVC? If so then it would seem to make sense to hold off updating dependencies until ASP.NET MVC is updated.
like image 893
Josh Avatar asked Feb 05 '13 21:02

Josh


1 Answers

jQuery deprecated the .live() method in v1.9. It can be replaced with .on(). This broke jquery.unobtrusive-ajax.js. I know from experience when cursing the update that I first pulled from NuGet.

There is an update to jquery.validate out there, also mentioned in this thread. But I have not validated it yet, jquery 1.9.1 is available as well.

For your questions...

  1. I think it is good practice to keep your packages upto date, but also research any deprecated functionality. Also using some source save like tools is a good idea. You could easily revert any breaking changes with one or two mouse clicks.

  2. Even though there is not a \packages folder added to you virgin project (intra or internet). If you open up the NuGet package manager UI, updates will still show up.

like image 56
cameronjchurch Avatar answered Oct 24 '22 05:10

cameronjchurch