O'Reilly logo

YUI 2.8 Learning the Library by Dan Wellman, Daniel Barreiro

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

The Element Utility

Of course the example we just saw is not really practical, but it gives a good idea of what we want and it will help us appreciate the way the YUI library allows us to handle it. The onRadioButtonsClick() function is a primitive event subscriber, and we could simply improve on that by using EventProvider. However, as soon as we wanted to add some extra functionality we would surely find that such a solution is very limited.

The reasonable solution is to define a class representing the set of radio buttons. Instead of creating the class from scratch, we will use YAHOO.util.Element as its basis. All the most recent YUI controls inherit from Element, and so will we.

Element is a wrapper around a DOM node. It is what an idealized ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required