I got a delete (input submit) button which pops up a dialog (Alloy UI dialog, html) when clicked:
A.all("#RFB input.ConfirmDelete").each(function(node){
node.on('click', function(event) {
if(confirmed) {
showUserWaitDialog();
return true;
}
else {
deactivateKeyboardNav();
deleteConfirm(node, confirmDeleteMessage, function () { //Runs the function rendering the pop up
confirmed = true;
event.target.click();
showUserWaitDialog();
});
}
});
});
The problem is that the event
is running async and thus performs the deletion, and not waiting for the user to click OK (calling the callback).
The deleteConfirm takes the following arguments
function deleteConfirm(link, pText, callback) {
The content in the pop up consists of:
var bodyContent = '<div class="vl-info vl-message"><h2>'+titleText+'</h2>'+
'<p>'+pText+'</p>' +
'<p class="more button-area"><a href="#" class="deleteOK">'+confirmButtonText+'</a><a href="#" class="deleteNotOK">'+discardButtonText+'</a></p></div>';
And the button functions:
A.one('.deleteOK').on('click', function(e){
(jQuery.isFunction(callback)) && callback.apply();
confirmDialog.close();
confirmDialogOpen = false;
});
A.one('.deleteNotOK').on('click', function(e){
confirmDialog.close();
confirmDialogOpen = false;
return false;
});
How should I approach this?