Reputation: 4562
I am trying to get an example of Knockout working in JsFiddle.
This all works on the Knockout website and this code is taken directly from there.
Everything works as expected in JSFiddle too except the REMOVE function.
Does anyone know why?
Thanks
Upvotes: 0
Views: 325
Reputation: 56557
Yeah, you need to tell KnockoutJS that you want to pass current data to removeSeat
. Do this with JavaScript's bind
function like this:
<a href="#" data-bind="click: $root.removeSeat.bind($root, $data)">Remove</a>
The first parameter of bind
is a context, i.e. what will be accessed via this
inside the function. Other parameters are normally passed to function. Read more about this in the documentation.
Upvotes: 1