-2

I've a knockout model with an array of objects into a validation group. I want to validate existing arrayitems before add a new one into the observableArray, and it's works, but only the first time error occurs. In next error cases, validationgroup shows "1 error or whatever" errors but CSS is not applied to the textbox. ¿Why CSS is applied only first time error happends?

I've a fiddle to reproduce de issue. Steps 1- press add data button 2- leave the textbox without value and press Add data again. Everything is ok, error is showing and css is applied 5- fill textbox with any value 6- press Add data and let the new textbox empty. 7- press Add data again. wow!! Why CSS is not applied????

https://fiddle.jshell.net/srg25j3b/19/

Thanks all.

4

1 回答 1

0

我在以下位置找到了解决方案:

https://github.com/Knockout-Contrib/Knockout-Validation/issues/520

当您将新对象添加到可观察数组时,您必须将 Validatable 扩展到您不想验证的属性。..

something = ko.observable().extend({
       validatable: true
     })
于 2016-03-11T16:18:20.507 回答