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

Re : Templated events and observes

$
0
0
One of the advantages of RequireJS and Steal is not polluting the global scope, so while your solution does work, you are just using global variables.

When Control processes an name in the curly braces, it first looks in the Control's options and then the window. So you can do this:

  1. define(['can', 'core/global/appState'], function(can,  AppState) {
  2.       return can.Controll({
  3.             defaults: {
  4.                   appState: AppState
  5.             }
  6.       }, {
  7.         init: function(element, options){
  8.         },

  9.         '{appState} change': function(ev, attr, how, newVal, oldVal) {
  10.             console.log('appState changed2', ev, attr, how, newVal, oldVal);
  11.         },

  12.    });
  13. });

Viewing all articles
Browse latest Browse all 3491

Trending Articles