How can I capture validation errors in a new Backbone.Model during instantiation?

后端 未结 4 1974
故里飘歌
故里飘歌 2021-02-10 06:20

It is easy to bind to the \'error\' event of an existing model, but what is the best way to determine if a new model is valid?

Car = Backbone.Model.extend({
  va         


        
4条回答
  •  太阳男子
    2021-02-10 06:52

    i encountered problem like it

    my solution

    ...
    
    var handler = function(model, error, context) {}
    
    try {
      cars.add({}, { error: handler })
    } catch (e) { }        
    
    ...
    

提交回复
热议问题