I have a ViewModel and i use that with ericmbarnard / Knockout-Validation.
In it i have this field:
self.checksum = ko.observable().extend({required: {message: " * Required"}});
In my html, this:
<input type="text" id="txtCheckSum" name="txtCheckSum" data-bind="value: checksum"/>
And I add the “input file” value with a javascript code. In this javascript code, I calculate the md5 file and then fill the field txtCheckSum. But unfortunately, this does not automatically fills my ViewModel.
So, when I call the check “viewModel.errors().length == 0”, I have an error like that is empty.
Help?
As mentioned in the comments the point of KO is to separate your data from your view. By using the jquery selectors to update the value of inputs you are essentially using KO wrong. In very few circumstances is plain jquery needed.
The correct approach would be to update the observable itself.
Then you can eliminate the $(“#txtCheckSum”).val/trigger all together.