Knockout-Contrib/Knockout-Validation

Validation on nested objects not working after changing whole object

Open

#398 ouverte le 28 janv. 2014

Voir sur GitHub
 (2 commentaires) (0 réactions) (0 assignés)JavaScript (394 forks)batch import
help wanted

Métriques du dépôt

Stars
 (1 024 stars)
Métriques de merge PR
 (Aucune PR mergée en 30 j)

Description

Hi, I have a problem with validating nested objects. I have following view model:

      var ViewModel = function (first) {
           this.person = ko.observable(new Person(first));

           this.changePerson = function () {
               this.person(new Person("changed"));
           };
      };

      var Person = function (first) {
           this.firstName = ko.observable(first).extend({
                required: true
           });
      };

everything works as expected as long as I do not call changePerson function. After calling change if I have element with data-bind="person().firstName" validation messages will not show. Working example (http://jsfiddle.net/MDhUR/). I found a work round to this issue - if I use to bind to firstName everything works as expected (http://jsfiddle.net/seRr5/1/) .

regards.

Guide contributeur