I am trying to upgrade from jQuery 1.x to jQuery 2.x.
I have jQuery 1.8 and jQueryUI 1.8, and now I want to upgrade to jQuery 2.x and enhance my web app.
So m
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.$element.focus(n)
- it is deprecated. Use setTimeout(function() { $element.focus(); }, n);
.$element.zIndex()
- it is deprecated.$.ui.keyCode.NUMPAD_*
constants - they are removed.$element.data('someWidget')
to retrieve widget instance. Use instance()
method: $element.someWidget('instance')
. Unlike other plugin methods, the instance()
method is safe to call on any element. If the element is not an instance of the given widget, the method returns undefined
: $('').dialog('instance') /* returns undefined instead of throwing Error */
.Original upgrade guides and full list of changes: