diff -r 000000000000 -r 40c8f766c9b8 src/cm/media/js/lib/yui/yui_3.0.0b1/examples/node/node-evt-delegation.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/cm/media/js/lib/yui/yui_3.0.0b1/examples/node/node-evt-delegation.html Mon Nov 23 15:14:29 2009 +0100 @@ -0,0 +1,210 @@ + + + + + YUI Library Examples: Node: Delegating Node Events + + + + + + + + + + + + +
+
+
+

+ + YUI 3.x Home - + +

+
+ + +
+ + + +
+
+
+
+

YUI Library Examples: Node: Delegating Node Events

+
+
+ +

Note: This is YUI 3.x. Looking for YUI 2.x?

+ +
+
+
+
+ +

Node: Delegating Node Events

+ +
+

+

This example demonstrates using a single event listener on a list to delegate clicks on the list items.

+ +

+ +
+
+ + + + +
    +
  • click me if you don't mind...
  • +
  • click me if you don't mind...
  • +
  • click me if you don't mind...
  • +
  • click me if you don't mind...
  • +
+ + + + + + +
+
+
+ +

Setting up the HTML

+

First we need some HTML to work with.

+ + +

Geting a NodeList Instance

+

We will use the all method of our YUI instance to get a NodeList instance to work with.

+ + +

Delegating Node Events

+

In this example, we will listen for a click event on the list and handle it at the item level and use information from the event object to update the nodes.

+ + +

Now we just assign the handler to the UL using the delegate method to handle clicks on each LI.

+ + +

Full Script Source

+ +
+ +
+ +
+
+ + + +
+ +
+

Copyright © 2009 Yahoo! Inc. All rights reserved.

+

Privacy Policy - + Terms of Service - + Copyright Policy - + Job Openings

+
+
+ + + +