You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I saw that all examples attach an "errors" property to an istance of a viewModel but I have a generic class which extends ViewModel
Emi.G.Masters = kb.ViewModel.extend({...
I have a viewModel with two observable. To check parseInputAttributes I set a required attribute in the javascript code and I used the HTML5 attribute "required" for the second one.
self.errors()().length is correctly 2 but error messages appears only in the title field, the one extended. And if I filled title with some string, self.errors()().length was 1 but no message appears.
The text was updated successfully, but these errors were encountered:
I saw that all examples attach an "errors" property to an istance of a viewModel but I have a generic class which extends ViewModel
Emi.G.Masters = kb.ViewModel.extend({...
I have a viewModel with two observable. To check parseInputAttributes I set a required attribute in the javascript code and I used the HTML5 attribute "required" for the second one.
this.title = ko.observable('').extend({required: true});
this.description = ko.observable('');
And then, an istance of my class
Emi.G.vm = new Emi.G.Masters;
Now, if I attach errors to the istance
Emi.G.vm.errors = ko.validation.group(Emi.G.vm);
and in the submit I checked errors like this
submit: function(self, e) {
if (self.errors().length != 0) {
self.errors.showAllMessages();
return;
}
all works but if I create a class method
errors: function() {
var self = this;
return ko.validation.group(self);
},
and
submit: function(self, e) {
if (self.errors()().length != 0) {
self.errors().showAllMessages();
return;
}
self.errors()().length is correctly 2 but error messages appears only in the title field, the one extended. And if I filled title with some string, self.errors()().length was 1 but no message appears.
The text was updated successfully, but these errors were encountered: