Skip to content
Go to file
Cannot retrieve contributors at this time
30 lines (24 sloc) 772 Bytes
<!doctype html>
<html lang="en">
<title>JavaScript Patterns</title>
<meta charset="utf-8">
/* Title: event delegation
Description: event delegation pattern and antipattern
// antipattern
// As of jQuery 1.7, the .live() method is deprecated
// $('a.trigger', $('#container')[0]).live('click', handlerFn);
// preferred
$('#container').on('click', 'a.trigger', handlerFn);
// .bind()
// .live() - best used for simple scenario, it functions the best with a supply selector only, it's not chainable
// .delegate() - it gives you a more focused way, it can better filter the elements, for example, table row
// References
You can’t perform that action at this time.