javascript - Y.Node addTarget event not bubbling -
why isn't event fired in foo
bubbling bar
?
var foo = y.one(".foo"), bar = y.one(".bar"); foo.addtarget(bar); foo.on("myevent", function () { //this log statement executes y.log("in foo listener"); }); bar.on("myevent", function () { //this log statement doesn't execute. //i don't understand why. think //should because expect myevent //bubble foo bar since used //addtarget y.log("in bar listener"); }); foo.fire("myevent");
js fiddle: http://jsfiddle.net/steaks/tjnlf/
you have publish myevent
foo
, set emitfacade
true
. http://yuilibrary.com/yui/docs/event-custom/#facade
yui().use('event-custom', 'node', function(y) { y.on('domready',function(e) { var foo = y.one(".foo"), bar = y.one(".bar"); foo.publish("myevent", { emitfacade: true }); foo.addtarget(bar); foo.on("myevent", function () { y.log("in foo listener"); }); bar.on("myevent", function () { y.log("in bar listener"); }); foo.fire("myevent"); }); });
Comments
Post a Comment