We have been using jQuery 1.4.2 in our web application. Recently it was suggested that we upgrade to a newer version. So far we are thinking about upgrading to 1.9.1 as we n
In addition to frenchie's answer, if your application injects custom html attributes from code-behind, at the client-side those attributes can still only be read using attr() instead of the new prop().
According to my current understanding this is because name-value attribute additions to elements are only recognized as properties when they are either native to the DOM element type, or have been added using the same client-side jQuery prop() method.
Doing a similar jQuery upgrade for the first time, I found this thread about the differences between attr and the new prop a very interesting read: prop-vs-attr
Just look at the deprecated functions still in your code; the big ones to watch out for are .live()
and .delegate()
which have been replaced with .on()
, .attr()
for which .prop()
is the replacement, and .browser()
. I've been updating my code as new versions came along and it's been pretty easy (about 20K lines of js) so you shouldn't have any problems. Just start with the functions I mentioned and I think that'll solve most of the issues. Then, look at the Migrate
plugin.
You can try to use jQuery Migrate plugins which is used to detect and restore APIs or features that have been deprecated in jQuery and removed as of version 1.9.
offset
option in position properties, e.g. code $element.position({my: 'center center', at: 'center center', offset: '5 -10'})
should be replaced with $element.position({my: 'center center', at: 'center+5 center-10'})
.$element.bind()
, $element.live()
, $element.delegate()
to assign event handler, use $element.on()
.$.browser
, try to use feature detection instead ($.support
).deferred.isRejected()
, deferred.isResolved()
, use deferred.state()
instead. Do not use deferred.pipe()
, the deferred.then()
method should be used instead.$elements.size()
method, use the $elements.length
property instead. The .size()
method is functionally equivalent to the .length
property; however, the .length
property is preferred because it does not have the overhead of a function call..trigger()
ed "click" event now has the same state as in a user-initiated action..data()
keys, e.g., ui-dialog
instead of dialog
. (http://jqueryui.com/upgrade-guide/1.9/#changed-naming-convention-for-data-keys).$.ui.contains()
, use $.contains()
instead.this.uuid
and event namespace this.eventNamespace = "." + this.widgetName + this.uuid
. Do not generate similar things manually.Original upgrade guides and full list of changes: