I been working on custom binding handlers to bind formatted value to my text-box and i'm pretty successful with that . Here i am adding a validation (required:true,number:true)
on the same text-box i'm referencing to .
Binding Handler Code:
ko.bindingHandlers.autoNumeric = {
//my code goes here
}
My binding handler code looks something like this
View :
<div data-bind="foreach:arraylist">
<input type="text" data-bind="autoNumeric:$data.Amount" />
</div>
ViewModel :
self.add = function(){
self.arraylist.push(new myfun());
}
When i click on add
i will add new row to the array with amount so here binding handler autoNumeric
will also gets fired because of the binding and observable associated which in-turn will make my validation fire and display error message enter something
which i want to avoid .
For validations i'm using validatedobservable
inside to it using .extend({required:true})
.
Any interesting suggestions are appreciated .