add

  • function
 

Creates a new scope with its parent set as the current scope.

scope.add(context)

Creates a new scope with its parent set as the current scope.

Parameters

  1. context {*}

    The context of the new scope object.

Returns

{can.view.Scope}

A scope object.

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 can.view.Scope(list).add(justin);

curScope.attr("name") //-> "Justin"
curScope.attr("length") //-> 2