Single click handler for all buttons in Javascript? Is it a pattern? Whats the benefit?

Posted by Hasan Khan on Programmers See other posts from Programmers or by Hasan Khan
Published on 2011-11-14T08:33:12Z Indexed on 2011/11/14 10:11 UTC
Read the original article Hit count: 458

I have been told that when there are multiple buttons on the page for same purpose but targeting different item e.g. delete item on a grid of items, they say it is recommended to just register for click handler only on the top most element like 'body' and check what was clicked instead of hooking up click with every delete button.

Whats the benefit of this? Creating more handlers causes problems? Is it an optimization of some sort? Is it a pattern? Does it have anything to do with performance? Where can I read more about it?

© Programmers or respective owner

Related posts about JavaScript

Related posts about web-applications