I have a HTML table that displays rows of records and has a column on the end with a delete link. Each delete link has a class of confirm-delete. I need to have a confirm dialog popup on click and as it is used in multiple pages, have created a confirm function in an external JS file.
I have added the function call to the link's click using jQuery [code at bottom of post] and it works fine until the dialog has been confirmed once [user has clicked OK]. Then the function is no longer called.
I think I am missing something pretty simple though as I don't use JS/jQuery much I may have a gap in my knowledge. Why does it work fine until the first OK? It appears to be storing a reference to the result and reusing it rather than a unique one for each link.
Here's the code when used on the Notes page:
$(function() {
// Add Confirmation dialogs for all Deletes
$("a.confirm-delete").click(function(event) {
return fConfirmDelete('Note');
});
});
And the fConfirmDelete function
function fConfirmDelete( deleteObj ) {
return confirm('Are you sure you wish to delete this ' + deleteObj + '?');
}