Backbone Validate does not work

后端 未结 4 762
小蘑菇
小蘑菇 2020-12-24 03:00

I am using Backbone\'s validate function to guarantee Man to have an age property more than 18. Here is my code:

var M         


        
4条回答
  •  一生所求
    2020-12-24 03:21

    var man = new Man({name : 'qian', age : 12}, {validate : true});
    

    EDIT:

    validate method works only in case if you pass an options object with validate param (from 0.9.9 version): https://github.com/documentcloud/backbone/blob/master/backbone.js#L539

    And it triggers not error event but invalid event

提交回复
热议问题