我有一个定义如下的视图模型:
var ViewModel = function() {
var self = this;
self.property1 = ko.observable().extend({ required: true });
self.property2 = ko.computed(function() {
return self.property1();
});
self.form_onsubmit = function (form) {
if (!self.isValid()) {
console.log("error");
}
return false;
};
};
$(function () {
ko.applyBindingsWithValidation(new ViewModel());
});
当我调用该form_onsubmit
函数时,发生错误:
TypeError: self.isValid is not a function
if (!self.isValid()) {
怎么解决,谢谢^^^