The YUILoader Utility is designed, of course, to help you put YUI components on the page. But your applications will frequently consist of a YUI-component foundation with your own application logic built on top. In other words, when you're loading YUI components you'll often want to load your own components as well.
yahoomaps module and, when we request it, the required files are brought into the page in the correct order.
Note 1: As of YUI 2.4.1, defining custom modules that override existing YUI skins requires a specific syntax. See the example code below for details. Note 2: Opera is not fully supported by the Yahoo! Maps AJAX API.
addModuleto Add Custom Modules via YUILoader
The purpose of this example is to illustrate one mechanism for adding custom (non-YUI) content to the page using the YUILoader Utility. For full documentation on this feature of the YUILoader, please refer to the "Using
addModule" section of the YUILoader Utility User's Guide.
Yahoo! Maps offers an excellent UI widget that allows you to put mapping magic on any HTML page. This widget requires some YUI base components, so an excellent way to put it on the page is to use the YUI Loader.
addModuleto Make YUILoader Aware of the Yahoo! Maps Module
This is a simple step in which we invoke
addModule and pass in relevant metadata about our new module:
Note that in this case we're setting up a dependency relationship between the
yahoomaps module and six standard YUI modules. YUI Loader, when asked to load
yahoomaps, will look at the current environment and load any of these requirements that aren't already present before loading the
addModule step is the most important elements of this example with respect to adding non-YUI content to the page via YUI Loader. The full source of the example, including the use of the YUI Button Control to actuate the loading of the maps widget, follows here.
The varName property is required for external scripts that need to run in Safari 2.x or lower.
This is the name a variable that the downloaded script will contain. The
will only be executed once this property is detected.
In version 2.4.1 of the YUI Loader, defining modules that override existing YUI skins requires that you load them in two phases: 1) The YUI component, 2) The custom component:
All YUI 2.x users should review the YUI 2.8.2 security bulletin, which discusses a vulnerability present in YUI 2.4.0-2.8.1.