DoneJS StealJS jQuery ++ FuncUnit DocumentJS
3.0.0
2.3.27

 

  • Github
  • Twitter
  • Chat
  • Forum
  • Guides
  • Core
  • Ecosystem
  • Infrastructure
    • can-construct
    • can-control
    • can-event
    • can-event/async/async
    • can-event/batch/batch
    • can-observation
    • can-simple-map
    • can-util
    • can-view-callbacks
    • can-view-live
    • can-view-model
    • can-view-nodelist
    • can-view-parser
    • can-view-scope
      • types
        • Meta
      • static
        • Options
      • prototype
        • add
        • compute
        • get
        • peek
        • set
    • can-view-target
  • Legacy
  • Bitovi
    • Bitovi.com
    • Blog
    • Consulting
    • Training
    • Open Source
  • Chat
  • Forum
  • Star
  • Follow @canjs
  • CanJS
  • /
  • Infrastructure
  • /
  • can-view-scope
  • /
  • add
  • / On this page
    • add

      function
      • source

      scope.add(context [,meta])

      Creates a new scope and sets the current scope to be the parent.

      var scope = new Scope([
         {name:"Chris"},
         {name: "Justin"}
      ]).add({name: "Brian"});
      scope.get("name") //-> "Brian"
      

      Parameters

      1. context {*}:

        The context to add on top of the current scope.

      2. meta {Meta}:

        A meta option that can be used to configure special behaviors of this context.

      Use

      scope.add(context) creates a new scope object that first looks up values in context and then in the parent scope object.

      var list = [{name: "Justin"},{name: "Brian"}],
          justin = list[0];
      
      var curScope = new Scope(list).add(justin);
      
      curScope.get("name") //-> "Justin"
      curScope.get("length") //-> 2
      

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