-
-
Notifications
You must be signed in to change notification settings - Fork 5.3k
Closed
Description
In my app, I noticed collection.invoke stopped forwarding arguments to individual method calls when I upgraded from Backbone 1.1.2 to 1.2.0.
I created a reduced example, and I'm not seeing sampleMethod log anything at all using 1.2.0. This example works properly with 1.1.2:
(Save as HTML to run)
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore.js"></script>
<!-- This test fails with 1.2.0: -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.2.0/backbone.js"/>
<!-- This test passes with 1.1.2: -->
<!-- <script src="https://cdnjs.cloudflare.com/ajax/libs/backbone.js/1.1.2/backbone.js"></script> -->
<script>
var SampleModel = Backbone.Model.extend({
sampleMethod: function (arg) {
console.log(arg);
}
});
var SampleCollection = Backbone.Collection.extend({
model: SampleModel
});
var sampleCollection = new SampleCollection();
sampleCollection.add(new SampleModel());
sampleCollection.invoke("sampleMethod", "sampleArg");
</script>
<p>If the test succeeds, you should see "sampleArg" printed in the console.</p>