Monday, January 21, 2013

How to migrate older jQuery code to jQuery 1.9+

jQuery team with their previous release has marked many methods/features deprecated but they were available with earlier jQuery releases. But with release of 1.9 version of jQuery many deprecated methods are discarded now and no longer available. Which are,

Related Post:
  • jQuery.browser docs
  • jQuery.fn.andSelf() docs
  • jQuery.sub() docs
  • jQuery.fn.toggle() docs (_event click signature only_)
  • "hover" pseudo-event name docs
  • jQuery.fn.error() docs
  • ajaxStart, ajaxSend, ajaxSuccess, ajaxError, ajaxComplete, ajaxStop global events on non-document targets docs
  • Use of attrChangeattrNamerelatedNodesrcElement on the Event object (use Event.originalEvent.attrChangeetc. instead)
  • jQuery.fn.attr() using the pass argument (undocumented)
  • jQuery.attrFn object (undocumented)
  • jQuery.fn.data() data events (undocumented)
  • jQuery.fn.data("events") to retrieve event-related data (undocumented)
But there are many sites in production which are still using these deprecated features and it's not possible to replace them overnight. So jQuery team provided with jQuery Migrate plugin that makes code written prior to 1.9 work with it.

This project can be used to detect and restore APIs, features or functionality that have been deprecated in jQuery and removed as of version 1.9. The plugin can be included with versions of jQuery as old as 1.6.4 as a migration tool to identify potential upgrade issues. However, the plugin is only required for version 1.9 or higher to restore deprecated and removed functionality.

This plugin comes in production and development version. To make it easier for jQuery developers to find and remove deprecated functionality, the development version of the plugin displays warnings on the browser's console.

Feel free to contact me for any help related to jQuery, I will gladly help you.