Skip to content

Instantly share code, notes, and snippets.

@meeech
Created November 29, 2010 15:51
Show Gist options
  • Save meeech/720111 to your computer and use it in GitHub Desktop.
Save meeech/720111 to your computer and use it in GitHub Desktop.
Making an example of what I'm trying to do to ask in the YUI help channels.
<!DOCTYPE html>
<html>
<head>
<title>IO Global Event?</title>
<script type="text/javascript" src="http://yui.yahooapis.com/combo?3.2.0/build/yui/yui-min.js"></script>
</head>
<body>
<p>Anyone know what I'm doing wrong here?</p>
<p>Would like 2nd codeblock to listen for all io:start events globally, but doesn't seem to work. </p>
<p>Am I just misunderstanding things? Example given of how I expect it to behave with the custom:event</p>
<script type="text/javascript" charset="utf-8">
//Normally, this would be loaded in another script on the page....
YUI().use('event', 'event-custom', function(Y) {
Y.Global.on('custom:event', function() {
console.log('Custom Event Received');
});
//Would like to listen to global IO start....
Y.on('io:start', function() {
console.log('start IO');
} );
//Maybe this? but it doesn't work either.
Y.Global.on('io:start', function() {
console.log('global? start IO');
} );
});
YUI().use('event', 'event-custom','io', function(Y) {
Y.on('domready', function() {
//This works...
Y.Global.fire('custom:event');
//Now, fire off an IO request
Y.io('test.html');
});
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment