Having a user confirm a selection is a very common occurrence when an action is performed. In this Knockout js tutorial I'm going to demonstrate how to ask the user to confirm their choice. Only when the user has clicked OK will the observable value be changed. This example will leverage the ko.extender to create a custom Knockout extender.
At my work, whenever we have a link to delete records, we always have a simple Javascript confirm dialog pop-up. The confirm dialog just does the standard, “Are you sure you wish to delete this record?” with an OK and Cancel button. If the user clicks cancel, the record is not deleted, if they click OK, the record will be deleted.
If you’ve done some Facebook development, you will notice quickly that the alert() and confirm() functions do not work. I’ve found this slightly annoying, so I’ve written a very simple Javascript function that let’s me use the nifty dialogs that Facebook provides us.