JSFiddle - React, Tailwind, and code Playground
by DOmEl
HTML
<body onload="Alert('dialog_message1','this is a test');">
<div id="divparent"
style="border: 1px solid red; height: 92px; width: 150%;">
</body>
CSS
.cancelButton
{
border: 1px solid #aaaaaa/*{borderColorContent}*/;
color: #FF0000/*{fcContent}*/;
}
JavaScript
var dynDiv;
var AlertTest = {
"message1": {
"buttons": [
{ id: "confirm", text: "Yes", handler: testconfirm },
{ id: "Cancel", text: "No",handler: testCancel}]
}
}
function Alert(id, params) {
dynDiv = document.createElement("div");
dynDiv.id = "message1";
document.getElementById("divparent").appendChild(dynDiv);
var test = dialog_box(dynDiv, eval("AlertTest" + '.' + dynDiv.id).buttons);
}
function testconfirm() {
alert( "testconfirm");
}
function testCancel() {
alert( "testCancel");
}
function dialog_box(dynDiv, dialog_buttons) {
var buttonPane = $("#divparent").parent().find('.ui-dialog-buttonset');
$(buttonPane).empty();
$.each(dialog_buttons, function(index, props) {
$("#message1").append('<span class="ui-button-text" id="btn' + props.id + '">' + props.text + '</span>');
$('#btn' + props.id).button().unbind('click').on("click", props.handler);
});
$(buttonPane).append("#" + dynDiv.id);
$("#message1").dialog({
modal: true,
appendTo: "#divparent",
show: "puff",
hide: "explode",
resizable: true,
closeOnEscape: false,
minWidth: 200,
minHeight: 150
});
$('.ui-dialog-buttonpane').find('button').addClass('cancelButton');
}