What is the difference in ko.validation.group
and ko.validatedObservable
? Are there particular situations when I should use one over the other?
相关问题
- implementing html5 drag and drop photos with knock
- knockout checked binding doesn't update
- Knockout JS - Binding to array of observable Ints
- Knockout.js autocomplete bindingHandler [closed]
- Javascript in Edge only works with devtools open
相关文章
- Handle IE 9 & 10's clear button with Knockout
- jQuery Chosen doesn't update select options wh
- KnockoutJS property doesn't update when changi
- knockout.js - data-bind text default value
- Setting default values for computed Observable Kno
- Mapping: foreach binding work only the first time
- Knockout radio button binding with boolean
- Ajax Post and Redirect with Model Value MVC4
The
ko.validation.group
just gives you an (computed) observable of all the error messages in a model. It only collects error messages of direct properties of the model.The
ko.validatedObservable
on the other hand not only collects the error messages, but also wraps the model in an observable and adds anisValid
property which indicates whether or not there are any error messages (i.e., the model was completely valid). Otherwise, they're essentially the same.If you're only interested in collecting the error messages, the
ko.validation.group
should be more than enough. If you need an observable that keeps track of whether or not the model is valid, theko.validatedObservable
does some of the work for you.