28 lines
740 B
JavaScript
28 lines
740 B
JavaScript
function showPopupWithCallback(myCallback, buttonText1, buttonText2, title, message) {
|
|
var popup = $("#popup-container");
|
|
|
|
var button1 = $("#popup-button-1");
|
|
var button2 = $("#popup-button-2");
|
|
|
|
$("#popup-title").text(title);
|
|
$("#popup-text").text(message);
|
|
|
|
setButtonOnclickAndValue(button1, function() {
|
|
myCallback();
|
|
}, buttonText1);
|
|
|
|
setButtonOnclickAndValue(button2, function() {
|
|
popup.hide();
|
|
}, buttonText2);
|
|
|
|
popup.show();
|
|
}
|
|
|
|
function setButtonOnclickAndValue(button, onclick, text) {
|
|
try {
|
|
button.on("click", onclick);
|
|
button.val(text);
|
|
} catch (error) {
|
|
console.log("%c Error: " + error.message, "color: red; font-weight: bold;");
|
|
}
|
|
} |