Wednesday, June 5, 2024
 Popular · Latest · Hot · Upcoming
62
rated 0 times [  68] [ 6]  / answers: 1 / hits: 21078  / 12 Years ago, thu, november 22, 2012, 12:00:00

I have read and read the docs on these two methods, but for the life of me cannot work out why you might use one over the other?



Could someone just give me a basic code situation where one would be application and the other wouldn't.


More From » backbone.js

 Answers
9

reset sets the collection with an array of models that you specify:



collection.reset( [ { name: model1 }, { name: model2 } ] );


fetch retrieves the collection data from the server, using the URL you've specified for the collection.



collection.fetch( { url: someUrl, success: function(collection) {
// collection has values from someUrl
} } );





Here's a Fiddle illustrating the difference.


[#81851] Wednesday, November 21, 2012, 12 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
elians

Total Points: 417
Total Questions: 87
Total Answers: 101

Location: Barbados
Member since Sun, Nov 27, 2022
2 Years ago
;