On my MVC project I have a View with 3 forms and one KO ViewModel
.
On each form I have a reset button to clear its own fields.
I can't use input type="reset"
because it doesn't update the observable values.
I can't either reset the View Model
because that will reset all the observables of the View Model
and I only need to reset the ones that are on the form that triggered the reset.
I can write 3 functions, one for each form and manually deleting each form fields like this:
this.onForm1Reset = function () {
this.field1('');
this.field2('');
//etc..
}
this.onForm2Reset = function () {
this.field3('');
this.field4('');
//etc..
}
this.onForm3Reset = function () {
this.field5('');
this.field6('');
//etc..
}
But I'm looking for a more global and a shorter solution.
I made a lot of researches online but couldn't find a good solution for that.
Any help would be very much appreciated.