Reputation: 311
while reading docs of backbone i can't understand how to add model to collection with option {at: index}
and then get this model using
mycollection.at('index')
?
When im doing
myCollection.add(myModel, {at: myindex});
then
myCollection.at(myindex)
returns undefined
;
Upvotes: 2
Views: 2244
Reputation: 8581
Based on what you've said, it could be that your collection just isn't that long enough and your myCollection.add(myModel, {at: myindex})
isn't able to splice it in.
Some demo code to replicate your problem:
// This is all done in the console
ships = new Backbone.Collection;
ship = new Backbone.Model;
ships.add(ship, {at:100});
myCollection.at(100); // undefined
myCollection.at(0); // model found
Maybe some sample code if this doesn't describe the issue?
Upvotes: 2