davy
davy

Reputation: 4562

Knockout tutorial not working in JsFiddle

I am trying to get an example of Knockout working in JsFiddle.

JsFiddle Here:

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

Answers (1)

freakish
freakish

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

Related Questions