Rewrite jQuery live() to on() syntax in CoffeeScript
jQuery 1.9+ has removed live() from event binding, but this is in light of having a better solution with their on() syntax. It's very easy to quickly rewrite any live() code using on(). Here's an example patch that I made to the bootstrap-tour library: bootstrap-tour patch for jQuery 1.9+
Before with live
$('a.tour-tip-close').live 'click', ->
After with on
$(document).on 'click', 'a.tour-tip-close', {} ->
Get more information on the jQuery documentation page for on()
Written by Arthur Chang
Related protips
1 Response
jQuery live() is a depreciated function in the first place because its too heavy, isn't it?
over 1 year ago
·
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Jquery
Authors
Did you know?
JavaScript on a page runs with the privileges of that origin. One altered library, tag manager, or snippet can read inputs, change what people see, and call your APIs as the user.
Security insights from Cside
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#