I must be doing something dumb, or maybe missing some crucial part of the Backbone documentation, but I cant understand why the Model.validate function is firing when I initialize a new Collection in this way: http://jsfiddle.net/5a3k/QSeH6/ ..any ideas where I’m going wrong?
edit: changed title
By executing this line:
You create new collection with one model. All models passed in the constructor will be added into the collection. Each added model is validated.
Details:
this.reset()(source)..reset()will silently add all the models into the collection (source)..add()will call internal._add()for each model (source).._add()will call.prepareModelwhich is checking if the model is valid (source).Update (based on edit in the question):
model.validateis executed only if the model is not instance ofBackbone.Model(source).So if you create a collection using
then the model is instance of
Object. But if you use:then the model is instance of
Backbone.Modeland validation is skipped.