Slide 154
Slide 154 text
Binding: Same syntax
154
// Old way of doing things
$('a').bind('click', myHandler);
$('form')
.bind('submit', { val: 42 }, fn);
$('.comment')
.delegate('a.add', 'click', addNew);
$('.dialog')
.undelegate('a', 'click.myDlg');
$('a').live('click', fn);
$('a').die('click');
// The new, simpler, hotness
$('a').on('click', myHandler);
$('form')
.on('submit', { val: 42 }, fn);
$('.comment')
.on('click', 'a.add', addNew);
$('.dialog')
.off('click.myDlg', 'a');
$(document).on('click', 'a', fn);
$(document).off('click', 'a');