Reputation: 2455
this is my model
Msg = Backbone.Model.extend({
validate: function(attr){
if(attr.msg === undefined || attr.msg === ''){
return "empty messege";
}
},
initialize: function(){
this.on('invalid',function(model,error){
console.log(error);
});
}
});
and I have collection of Msgs msgCollection
so if I do msgCollection.create({msg:''});
this model gets added to collection
how can I prevent this
Upvotes: 0
Views: 44
Reputation: 10044
For the record!
Pass
{wait:true}
as an option when you call create:
msgCollection.create({msg:''}, {wait:true});
Upvotes: 1