jQuery in Action

Putting it all together
259
In the top part of the figure we see the Features description of the item with the
terms Full-grain and Cambrelle highlighted. Clicking Full-grain causes the flyout
containing its definition to be displayed as shown in the bottom part of the figure.
We could hard-code everything to make this happen right on the page, but
we're smarter than that. As with our extensions to manipulate the select elements,
we want to create a reusable component to use elsewhere on this, or any other,
site. So once again, being jQuery-savvy, we'll implement it as a jQuery command.
8.5.1 Implementing the flyout behavior
As we recall, adding a jQuery command is accomplished by use of the
$.fn
prop-
erty. We'll call our new plugin that looks up the definitions of terms The Termifier,
and the command will be named
termifier()
.
The
termifier()
command will be responsible for instrumenting each ele-
ment in its matched set to achieve the following goals:
Establish a
click
handler on each matched element that initiates the dis-
play of The Termifier flyout.
Once clicked, the term defined by the current element will be looked up
using a server-side resource.
Once received, the definition of the term will be displayed in a flyout using
a fade-in effect.
Figure 8.9
The before and after shots
of the behavior that we'll be
adding to the page


Другие страницы

 
Cкачать книги бесплатно без регистрации в электронном виде (pdf, chm, txt).Вы можете читать книги онлайн на нашем сайте литературного портала книг.Большая подборка учебников, пособий, интересных книг.Электронные книги на английском языке скачать бесплатно без смс.

OK

Loading...
...
Закрыть