How would I go about using a jQuery UI dialog to confirm whether they want to delete a row from a a list within a KnockoutJS template?

As I see it, the Knockout demos show a template which renders each row in a grid.
The delete button calls the viewModel.remove() function passing in the object of the row to delete. Inside the remove() function, this.Gifts.Remove() is called with the data passed into the function as a parameter.

My problem is that I want to display a jQuery dialog to ask for confirmation of whether a row should be deleted. JQuery dialog works on the basis of a setup function which sets up the dialog and its delete function beforehand.

When I click on my delete link in the template, it opens the dialog ok, but how do I pass the template data into the dialog delete function, as it is now completely decoupled from the template mechanism?

Is there any way to test that the dialog method was called with the correct parameters? It would be to be able to test the interactions between the methods on the model and the jQuery UI. For example, to ensure that the buttons were bound correctly, that modal was true, etc. Is there a good way to do this? Thanks
–
Erick TSep 13 '11 at 0:10

jQuery UI moves the dialog to the bottom of the page and then Knockout's initial pass of binding all the elements hits it again. You can either initialize the widget in a setTimeout like this: jsfiddle.net/rniemeyer/WpnTU or it would work properly if you called ko.applyBindings(yourViewModel, someElement), as jQuery UI moves it to be the last element and it would not get bound if the bindings were scoped to a certain root element (other than body).
–
RP NiemeyerJul 29 '13 at 13:12