JSFiddle - React, Tailwind, and code Playground
JavaScript
function confirmDialog(message) {
var ready = -1;
var onOK = function(){
ready = true;
}
var onCancel = function(){
ready = false;
}
$('<div>' + message + '</div>').dialog({
modal: true,
buttons : {
"OK" : function() {
$(this).dialog("close");
// if there is a callback, execute it
if (onOK && $.isFunction(onOK)) {
onOK();
}
// destroy the confirmation dialog
$(this).dialog("destroy");
},
"Cancel" : function() {
$(this).dialog("close");
if (onCancel && $.isFunction(onCancel)) {
onCancel();
}
$(this).dialog("destroy");
}
}
});
var isOk = function(){
if (ready === -1){
isOk();
}
return ready
}
return isOk();
}
$(document).ready(function(){
confirmDialog("Test");
alert("done");
});