Chapter 16. Ajax Toolkits
There are many Ajax toolkits available for download, and most of them are free. For this chapter, we're using the Yahoo! User Interface (YUI) Library (developer.yahoo.com/yui/). YUI is a freely downloadable, open-source set of utilities and controls that help you build interactive Web applications. We think it's one of the best. In this chapter, we'll show you how to use YUI to enable the user to drag-and-drop page elements; add calendar objects; create overlays and pop-up windows; add cool animation effects to your pages; and finally, embed a light-weight debugger right in your page to help you create your applications.
The files you'll need to upload will vary, depending on the library components that you'll be using, but all of them require the Yahoo! Global Object, yahoo.js. This file provides the namespace that contains all YUI code (that is, the YAHOO objects referred to in step 5 on page 394). You must include the Yahoo! Global Object on every page that uses a YUI component, and it must appear on the page before any of the other components, so that it loads first. YUI components that require other components to work are said to be dependent on those components, and a component can require more than one dependency.
You include the Yahoo! Global Object by adding a <script> tag that specifies it, like so:
Then, add additional <script> tags for each of the other YUI components and (if necessary) their dependencies.
Note that this means that you're running these files off your own server, so if and when Yahoo! upgrades its code, you won't get the fixes automatically. Be sure to check back regularly to see if there are newer versions available.