我正在尝试运行以下代码:
var eligible = Backbone.Model.extend({
validate : function(attrs,options){
//alert("ldsafh");
if(attrs.min < attrs.max) {
return "not eligible for voting";
}
}
});
var age = new eligible({
advice : "You are "
});
age.on("invalid", function(model, error) {
alert("sfndxgj");
console.log(model.get('advice') + " " + error);
});
age.set({
min : 18,
max : 100
});
为什么这个 age.on 事件不起作用?请在这里帮我....