35 lines
732 B
Plaintext
35 lines
732 B
Plaintext
When using the Backbone.js framework, the array of models inside a collection, ``++collection.models++``, should not be accessed directly. Doing so bypasses the listeners set on the collection and could put your application in a bad state.
|
|
|
|
|
|
Instead, use ``++get++``, ``++at++`` or the underscore methods.
|
|
|
|
|
|
== Noncompliant Code Example
|
|
|
|
----
|
|
myCollection.models.forEach(function (model) { });
|
|
----
|
|
|
|
|
|
== Compliant Solution
|
|
|
|
----
|
|
myCollection.forEach(function (model) { });
|
|
----
|
|
|
|
|
|
ifdef::env-github,rspecator-view[]
|
|
|
|
'''
|
|
== Implementation Specification
|
|
(visible only on this page)
|
|
|
|
include::message.adoc[]
|
|
|
|
'''
|
|
== Comments And Links
|
|
(visible only on this page)
|
|
|
|
include::comments-and-links.adoc[]
|
|
endif::env-github,rspecator-view[]
|