DoneJS StealJS jQuery ++ FuncUnit DocumentJS
3.0.0
2.3.27

 

  • Github
  • Twitter
  • Chat
  • Forum
  • Bitovi
    • Bitovi.com
    • Blog
    • Consulting
    • Training
    • Open Source
  • Chat
  • Forum
  • Star
  • Follow @canjs
  • computeData
  • / On this page
    • computeData

      function
      • source

      scope.computeData(key)

      Parameters

      1. key {can-mustache.key}:

        A dot seperated path. Use "." if you have a property name that includes a dot.

      2. options {can-view-scope.readOptions}:

        Options that configure how the key gets read.

      Returns

      {Object}:

      An object with the following values:

      Use

      scope.computeData(key, options) is used heavily by [can-mustache] to get the value of a [can-mustache.key key] value in a template. Configure how it reads values in the scope and what values it returns with the [can-view-scope.readOptions options] argument.

      var context = new Map({
        name: {first: "Curtis"}
      })
      var scope = new Scope(context)
      var computeData = scope.computeData("name.first");
      
      computeData.scope === scope //-> true
      computeData.initialValue    //-> "Curtis"
      computeData.compute()       //-> "Curtis"
      

      The compute value is writable. For example:

      computeData.compute("Andy")
      context.attr("name.first") //-> "Andy"
      

      CanJS is part of DoneJS. Created and maintained by the core DoneJS team and Bitovi. Currently 3.0.0.