Knockout验证不适用于多个VM

时间:2013-11-07 09:29:41

标签: knockout.js knockout-validation

出于某些奇怪的原因,敲除验证不起作用。

这是我的代码:

var searchViewModel = function () {
    this.priceTo = ko.observable();
    ...
}

var searchVM = new searchViewModel();
searchViewModel["errors"] = ko.validation.group(searchViewModel );
var validationOptions = {
    insertMessages: true,
    decorateElement: true,
    errorElementClass: "errorFill",
    errorMessageClass: "errorFill"
};
ko.validation.init(validationOptions);

ko.applyBindings(searchVM, $("#searchSection")[0]);

我也尝试修改

searchViewModel["errors"] = ko.validation.group(searchViewModel);
像这样:

searchVM["errors"] = ko.validation.group(searchVM);

没有任何结果。

0 个答案:

没有答案