Skip to content

Instantly share code, notes, and snippets.

@ghinch
Created June 9, 2010 00:45
Show Gist options
  • Save ghinch/430875 to your computer and use it in GitHub Desktop.
Save ghinch/430875 to your computer and use it in GitHub Desktop.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<script type="text/javascript" src="http://yui.yahooapis.com/combo?3.1.1/build/yui/yui-min.js"></script>
<title>Test</title>
</head>
<body>
<div>
<h1>Testing</h1>
</div>
</body>
<script type="text/javascript">
// Define a module that adds a "domready" listener
YUI().add('test-mod', function (Y) {
Y.on('domready', function () {
var bod = Y.one('body'),
newHeading = Y.Node.create('<h2></h2>');
newHeading.set('innerHTML', 'DOM Ready');
bod.appendChild(newHeading);
});
}, '1.0', {
requires : ['node', 'event']
});
// Define two modules that require the first
YUI().add('test2-mod', function (Y) {
}, '1.0', {
requires : ['test-mod']
});
YUI().add('test3-mod', function (Y) {
}, '1.0', {
requires : ['test-mod']
});
</script>
<script type="text/javascript">
// Use one of the two modules requiring test-mod
YUI().use('test2-mod', function (Y) {
// will run test-mod and add the 'domready' listener
});
</script>
<script type="text/javascript">
// Use the other module requiring test-mod
YUI().use('test3-mod', function (Y) {
// also runs test-mod and re-adds the 'domready' listener
});
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment