0
我使用Knockout-Validation框架来验证viewModel。如何在计算出的属性中获得可观察属性的值Knockout-Validation
我有以下定义的视图模型:
ko.validation.init({
decorateElement:true,
errorElementClass: 'invalid',
insertMessages: false
});
var viewModel = ko.validatedObservable({
propety1: ko.observable().extend({ required: true }),
propety2: ko.computed(function() {
return this.propety1();
}, this),
form_onsubmit: function(form) {
console.log(this.propety1());
return false;
}
});
$(function() {
ko.applyBindings(viewModel);
});
它可以得到property1的在form_onsubmit函数值,但开不不是在计算财产“property2”工作。
如何解决它,谢谢!!!!!!!!!