Fetching contributors…
Cannot retrieve contributors at this time
48 lines (40 sloc) 2.17 KB
$loader = new YAHOO_util_Loader($yuiCurrentVersion);
//Specify YUI components to load
<title>YUI PHP Loader Utility Advanced Example: Mixed Loading Methods</title>
//Output the CSS link tags
echo $loader->css();
<body class="yui-skin-sam">
<h1>YUI PHP Loader Utility Advanced Example: Mixed Loading Methods</h1>
<p>In this example, we bring a YUI component onto the page using the <a href="">YUI PHP Loader Utility</a>.
This example implements YUI PHP Loader via a <code>YAHOO_util_Loader</code> instance. We include the YUI PHP Loader class file, then specify in
configuration which component we want loaded on the page &mdash; and what we want to do once it <em>is</em> loaded. The main difference between
this example and the previous advanced example is that we have mixed the component loading methods. The Calender component requires the Yahoo, Dom,
and Event modules. In the previous example we let PHP Loader bring these into the document for us. However, in this case we placed a static
script include into the document that brings in these resources. We do not wish to have PHP Loader duplicate the loading of these components so
we utilize the <em>setLoaded</em> method to notify PHP Loader that we already have these components in the document and to skip loading them a second time.</p>
<div id="calendar_container"></div>
<script type="text/javascript" src="<?PHP echo $yuiCurrentVersion; ?>/build/yahoo-dom-event/yahoo-dom-event.js"></script>
//Output the script tags (but don't re-include yahoo-dom-event)
$loader->setLoaded("yahoo", "dom", "event");
echo $loader->script();
<script type="text/javascript">
YAHOO.util.Event.onAvailable("calendar_container", function() {
var myCal = new YAHOO.widget.Calendar("mycal_id", "calendar_container");