简体   繁体   中英

knockout validation group css applies only first time error happends

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.

I found the solution on:

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

When you add new object to observable array you have to extend validatable to the properties you wan't to validate. ..

something = ko.observable().extend({
       validatable: true
     })

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM