:::: MENU ::::

jQuery live() shim for jquery-migrate 3+

jQuery version 3+ removed jQuery’s function $.live() and if your are using some old cms/shopping cart (like Interspire) that doesn’t upgraded their javascript functions, upgrading jQuery 3+ could lead to break your site.

jQuery.live() for jQuery 3+

All we need to do is, use .on() function write wrapper for .live()

jQuery on() function takes “event value” and “child selector” as string, while old live function could take object to chain it to live() function. So, old code could break if we don’t supply object selector as string.

Also live() function was dependent on properties like “$.selector” & “$.context”. However jQuery library 3+ also removed properties like “selector” and “context” which are required for legacy live function. So we need to make some workaround to create those properties. “.selector” for .live() could be created by string read selector’s ID while “.context” could be done by using selector’s parent() object.

Code Pen Demo:-

See the Pen jQuery Live for 3+ by vikaskbh (@vikaskbh) on CodePen.dark

jQuery Browser property for jQuery 3+

jQuery 3 also removed $.browser property. So some old code might break on third-party cms. I’ve used jQuery migrate 1+ to append it to existing jquery-migrate 3+.

Just append above two snippets in one of your own hosted jquery-migrate file and it should fix the issue related them.