attr
can.Observe.List.prototype.attr
Get or set elements in a List.
list.attr()
Gets a collection of all the elements in this can.Observe.List
.
Returns
{Array}
array with all the elements in this List.
Get or set elements in a List.
Gets a collection of all the elements in this can.Observe.List
.
{Array}
array with all the elements in this List.
attr
gets or sets elements on thecan.Observe.List
it's called on. Here's a tour through how all of its forms work:Deep properties
attr
can also set and read deep properties. All you have to do is specify the property name as you normally would if you weren't usingattr
.The discussion of deep properties under
attr
may also be enlightening.Events
can.Observe.List
s emit five types of events in response to changes. They are:The change event
The first event that is fired is the change event. The change event is useful if you want to react to all changes on an List.
The parameters of the event handler for the change event are:
'add'
,'remove'
, or'set'
.undefined
if elements were removed.undefined
if elements were added.Here is a concrete tour through the change event handler's arguments:
The set event
set events are fired when an element at an index that already exists in the List is modified. Actions can cause set events to fire never also cause length events to fire (although some functions, such as
splice
may cause unrelated sets of events to fire after being batched).The parameters of the event handler for the set event are:
Here is a concrete tour through the set event handler's arguments:
The add event
add events are fired when elements are added or inserted into the List.
The parameters of the event handler for the add event are:
Here is a concrete tour through the add event handler's arguments:
The remove event
remove events are fired when elements are removed from the list.
The parameters of the event handler for the remove event are:
Here is a concrete tour through the remove event handler's arguments:
The length event
length events are fired whenever the list changes.
The parameters of the event handler for the length event are:
If events were batched when the length event was triggered, length will have the length of the list when
stopBatch
was called. Because of this, you may recieve multiple length events with the same length parameter.Here is a concrete tour through the length event handler's arguments: