YUI Library Examples: Container Family: One Tooltip, Many Context Elements

Container Family: One Tooltip, Many Context Elements

In the example below, a single Tooltip instance is used to create tooltips for each link in the list.

Setting up the Tooltip

Tooltip can be configured to reuse a single Tooltip for multiple context elements with title attributes — by default, Tooltip will autopopulate its text configuration property with the contents of its context element's title attribute. Reuse of Tooltip instances is an advisable performance enhancement strategy, especially when you have a large number of context elements that need to invoke Tooltips.

In this tutorial, we will dynamically create many links, and then associate a single Tooltip with all of the generated links. This is achieved by setting the context property to an array of element ids (see the last line in the code block below, where contextElements is an array of element ids).

Copyright © 2007 Yahoo! Inc. All rights reserved.

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