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」工作。
如何解決它,謝謝!!!!!!!!!