44 lines
857 B
Plaintext
Raw Normal View History

== Why is this an issue?
2021-04-28 16:49:39 +02:00
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
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,javascript]
2021-04-28 16:49:39 +02:00
----
myCollection.models.forEach(function (model) { });
----
=== Compliant solution
2021-04-28 16:49:39 +02:00
2022-02-04 17:28:24 +01:00
[source,javascript]
2021-04-28 16:49:39 +02:00
----
myCollection.forEach(function (model) { });
----
ifdef::env-github,rspecator-view[]
'''
== Implementation Specification
(visible only on this page)
=== Message
Use "get|at" or the underscore methods instead.
'''
== Comments And Links
(visible only on this page)
=== on 20 May 2015, 12:32:24 Linda Martin wrote:
OK!
endif::env-github,rspecator-view[]