Monday, April 14th, 2008
Event Delegation for blur and focus
Over at Quirksmode.org, Peter-Paul Koch is researching if Event Delegation which works splendidly with click events is also possible for blur and focus.
Event Delegation means that you piggy-back on the behaviour of browsers to report events on child nodes up the tree to their parents. Instead of applying event handlers to each element you apply a single one on the main parent element and use the event target to determine which element was activated.
The benefits of Event Delegation are that you use a single event handler for a unknown amount of nodes. This is very handy when it comes to developing dynamic menus where the data is pulled via Ajax.
So far, PPK found that apart from IE all browsers play along, and there is a test page to give him feedback.












“.. that apart from IE…” Ah, the usual twist. ;) I believe Hedger Wang looked into some similar stuff with blur and focus.
So true, so many articles on many a modern technique have a trailing sentence, “oh this doesn’t work in the browser/s the majority of people use”. It’s great to see this stuff figured out but frustrating to see it rendered mostly unusable.
Looking at the test page, it looks like it actually does handle IE using the onfocusin and onfocusout events that IE has.
Nice stuff… I used this trick. we did an web app with javascript and because of the memory leaks we introduced this way of handling events: jdistill.com. there is only one event handler that is on the body element
JavaScriptMVC’s Controller class has event delegation for blur focus cross browser. It even does submit.
As a professional IT study materials provider, Pass4sure is specially designed for IT candidates who want to pass any IT exams, supported by a powerful team for product research and development, as well as website development and operation. Its vendors like Cisco, Microsoft, IBM, Sun, compTIA, HP, etc, are all positioned as leaders in the IT field.The Most Popular exams List :N10-004642-661 640-822 HP0-J33 642-975 640-721 350-030 HP0-S21 1Y0-A08 000-331 642-105 642-642BH0-004 350-050 350-030 312-50 HP0-J22 312-50 HP0-S20 642-975 352-001 642-067 640-802 Click Pass 4 Sure to get more information!