Hey, so trying to clarify my example... the following code is based
on JMVC
There are no external dependencies and you can see a fiddle here >>>
$('html').html('<div
class="fab">fab</div>');
$.Controller('EventSource',{},{});
$.Controller('EventDestination',{},{
"{EventSource} boomd1":function() {
console.log("booomd1"); },
"{EventSource} boomd2":function() {
console.log("booomd2"); }
});
ed
= new EventDestination($('div.fab'));
es = new
EventSource($('div.fab'));
$(EventSource).trigger("boomd1");
$(EventSource).trigger("boomd2");
Basically i am switching to CanJS and needed a way to do
something similar
The following is CanJS based
var EventSource = can.Control.extend("EventSource",{},{});
var EventDestination = can.Control.extend("EventDestination",{},{
'{EventSource} testevent':function(){
console.info('testevent'); },
'{es} zzz':function(){ console.info('zzz'); }
});
es = new EventSource();
ed = new EventDestination();
// this doesnt seem to work
can.trigger(EventSource, "testevent");
see fiddle: https://jsfiddle.net/qYdwR/2434/
Unfortunately i cant get this to work.. i.e. nothing in the
console log
Thanks