Skip to content

Instantly share code, notes, and snippets.

@ghinch
Created July 21, 2010 01:36
Show Gist options
  • Save ghinch/483900 to your computer and use it in GitHub Desktop.
Save ghinch/483900 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>
<title>untitled</title>
<script type="text/javascript" src="http://yui.yahooapis.com/combo?3.1.1/build/yui/yui-min.js"></script>
</head>
<body>
<div id="widget1">Widget 1</div>
<script type="text/javascript">
YUI().use('widget', function (Y) {
var Widget1 = Y.Base.create('widget1', Y.Widget, [], {
initializer : function () {
var cusEv = this.publish('widget1:someEvent', {
broadcast : 2,
monitored : true,
emitFacade : true
});
cusEv.monitor('attach', function (e) {
// not getting picked up
console.log('attached');
});
}
});
var w1 = new Widget1({
contentBox : '#widget1',
render : true
});
Y.later(2000, this, function () {
console.log('firing event');
w1.fire('widget1:someEvent');
});
});
</script>
<div id="widget2">Widget 2</div>
<script type="text/javascript">
YUI().use('widget', function (Y) {
var Widget2 = Y.Base.create('widget2', Y.Widget, [], {
bindUI : function () {
Y.Global.on('widget1:someEvent', function (e) {
console.log(e);
});
}
});
var w2 = new Widget2({
contentBox : "#widget2",
render : true
})
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment