thedersen/backbone.validation — Issue #18: Model Validation When Views use a Collection vs. a Model
Author: dubelyoo
Created: 2012-01-23 15:27:51+00:00
State: open

I often create a view with a collection vs. a model when I want to add a new model to the collection. Using the collection.create() method works well, easy, etc. I feel like it gets messy when you try to create a view w/a model then add it to the collection as you need to reference both.

var view = new View({
collection: myCollection,
id: 'my-view'
});

Later on when I want to create the model I just use this:

this.collection.create({
attr1: value,
attr2: value
});

The normal backbone validation methods would kickoff on the save but of course I want to use backbone.validation. My issue is that backbone.validation looks for the view's model and does not consider a view's collection. I apologize if I've missed something in the documentation (or don't understand something about backbone itself) but it didn't jump out at me. Thoughts?