Last Updated: February 25, 2016
· artchang
Photo sep 26  14 31 57

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

Say Thanks

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 ·