The fifth feature of our customer registration form application is to capture the customer's interests. The interest categories are sports, news, movies, and comedy. We will capture the interests using checkboxes.
Let's start by creating the interests attribute in our customer
model. This attribute will hold the values of the interests selected by the customer. This attribute will be an observable array as we need to allow the customer to select multiple interest categories. Add the following code to the customer
model:
interests: ko.observableArray()
We will now update the view to add the checkboxes and bind them to the interests attribute. Add a fieldset
element and interests section header, similar to the previous sections. Add a div
element, which will hold our interest checkboxes. Add the interest checkboxes and give them values of the interest categories. Bind the checkboxes to the interests attribute of the model. The interests fieldset
should look similar to this...