Last Updated: February 25, 2016
·
4.639K
· artchang

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()

1 Response
Add your 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
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