Skip to content

Instantly share code, notes, and snippets.

@Pamblam
Created August 16, 2017 14:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Pamblam/df324a21ffd2f8a8e5cef087442f6109 to your computer and use it in GitHub Desktop.
Save Pamblam/df324a21ffd2f8a8e5cef087442f6109 to your computer and use it in GitHub Desktop.
function confirm(msg) {
return new Promise(function(yip, nip) {
var $div = $("<div>");
$div.html(msg);
$("body").append($div);
$div.dialog({
buttons: [{
text: "Yes",
icon: "ui-icon-heart",
click: function() {
$div.remove();
yip();
}
}, {
text: "No",
icon: "ui-icon-closethick",
click: function() {
$div.remove();
nip();
}
}],
close: function(event, ui) {
$div.remove();
}
});
});
}
confirm("your mom").then(function(){
alert("You clicked yes");
}, function(){
alert("you clicked no");
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment