The final feature of our application is to clear the customer registration form. We will add a button, which the customers can click on to clear any input in the form fields. We will add a corresponding method in the module that will clear all observables in the model.
Let's start by updating the view. Next to the Submit
button, add a button to view. Label the button Clear
. Bind the click event of the button to a method in the module. We will call this method "clear"
. Your code for button should look similar to this:
<button type="button" class="btn btn-default" data-bind="click: RegistrationForm.clear">Clear</button>
Now that we have updated the view, we can add the clear method to our module. Open the model and add the method skeleton. Also, add the method to the return
statement of the module. There are a few different ways of clearing the module. You can set the value of each observable in the module by manually calling its setter method. We will...