Quantcast
Channel: JavaScriptMVC Forum
Viewing all articles
Browse latest Browse all 3491

Re : Start listening for event in Control.

$
0
0
Hi,

I am not an expert (yet) so i don´t know if this solution is overkill, but if you are talking about different "objects" that somehow are behaviour dependent, you can use "can.compute" to implement an observable to "mousedown" event, something like:
var mousedown = can.compute(false);

#id1 mousedown': function(){
      mousedown(true);
}

'{mousedown} change': function(){ ... }
     do whatever you want change is true;
     do whaterver you want if change is false;
});

You can share also this computes between controls (if that fits to your case):
      mousedown = can.compute(false);

      new AControl('element', {mousedown: mousedown})
      new BControl('element', {mousedown: mousedown})

      In AControl you can set mousedown value: mousedown(true);
      In BControl you can listen for mousedown change: "{mousedown} change": function(){...}


Cheers,
Linton Fernandes

Viewing all articles
Browse latest Browse all 3491

Trending Articles