Here I have an example code:
<div data-bind="foreach: someData1">
<a href="#" data-bind="click: myFunction"></a>
</div>
<div data-bind="foreach: someData2">
<a href="#" data-bind="click: myFunction"></a>
</div>
How inside myFuncion code to know when it's called: when foreaching someData or someData2?
You can access both the item and the click event in myFunction.
ReplyDeleteviewModel.myFunction = function (item, event) {
// event.target = <a>
};
You should check out the official Knockout documentation for the click binding.