event-node.mustache revision fb1ecdf65fd4106deb62da339763f2e7670ca0f6
2N/A<p>Next we will add a handler to run when the event is fired. In our handler we will update the node with the <code>type</code> of the event.</p>
2N/A<p>Note that the event handler receives an event object with its <code>currentTarget</code> set to the current Node instance, and the actual node clicked as the <code>target</code>. The context of the handler is the NodeList instance, so <code>this</code> refers to our NodeList instance.</p>
2N/A this.addClass('yui-pass');
2N/A<p>We can assign our handler to all of the items by using the <code>all</code> method to get a <code>NodeList</code> instance and using the <code>on</code> method to subscribe to the event.</p>
Y.all('#demo li').on('click', onClick);