The click event
We have been using the click binding in the last three chapters. In this one, you are going to learn more about this event. The click event is the basic event that users use to interact with an application since the mouse has been the peripheral par excellence (also the keyboard).
You must have learned that if you attach a function to the click binding, this function is fired with the click event. The problem is that in Knockout the click event doesn't accept parameters. The arguments of our click function are predefined, as far as we know.
Passing more parameters
As we have mentioned, the function we bind to the click event has a predefined signature: function functionName(data, event){...}
, and both the parameters are already assigned: data is the data bound to the element and event is the click event object. So what happens if we want to pass more parameters? We have three solutions, which are as follows:
The first one is to bind the parameters in the view-model:
function clickEventFunctionWithParams...