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

Re : Working with Observables and computes

$
0
0
It's fine to just use computes if that's what you need. One way to beter leverage the two is to create computes from your Observe so you don't have to manually update the Observe when a compute changes:

  1. this.options.obsSelectLists = can.Observe({course : -1, courseyear: -1, discipline: -1});
  2. var course = this.options.obsSelectLists.compute('course')
  3. var courseyear = this.options.obsSelectLists.compute('courseyear')
  4. var discipline = this.options.obsSelectLists.compute('discipline')
  5. //Then pass these into the Controls
when one of the computes is updated, the Observe will be updated and vice versa. 

**Also be sure to use the new keyword with can.Observe

Viewing all articles
Browse latest Browse all 3491

Trending Articles