3
votes

I am designing a viewmodel object in knockout that has an observable array. When submitting the form, jquery validation plugin is taking care of all this, but instead of showing the errors in the screen, i would like to fill the observable array and let the screen update by itself (due to the magic of ko bindings). Is this possible?

1

1 Answers

1
votes

Look at the showErrors option in the jQuery validate plugin documentation. You can specify a function that will be invoked with the errors, at which point you could add them to your observable array:

$(".selector").validate({
   showErrors: function(errorMap, errorList) {
    ko.utils.arrayPushAll(myArrayOfErrors, errorList);
  }
})