Home > SharePoint > Beware of upgrading JQuery version in existing customizations

Beware of upgrading JQuery version in existing customizations

2012/04/21

When reviewing old SharePoint customizations we can encounter code written with the JQuery version available at the time when the customization was written, for example 1.6.2, and we can tempted to change the version, for example change from

<script src=”http://ajax.googleapis.com/ajax/libs/jquery/1.6.2/jquery.min.js&#8221; type=”text/javascript”></script>

To

<script src=”http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js&#8221; type=”text/javascript”></script>

because we can think that the newer version is better, with less bugs…

Don’t’ do this ! JQuery is evolving and a syntax ,of a selector for example, that was working with the version used at the time of the customization could not work anymore in a new version .

For example with the 1.6.2 this syntax for selecting the third column of a List view is working:

var arr = $('td.ms-vb2[cellIndex=2]');

With the above code you have an object array with all the cells of the third column.

But if you change to 1.7.2 the version of the script in the <script src this code does not work more , breaking the once working customization!

With JQuery 1.7.2 the equivalent (working) syntax is

var arr = $("td.ms-vb2:nth-child(3)");

Advertisements
Categories: SharePoint
%d bloggers like this: