Skip to content

Instantly share code, notes, and snippets.

@6ui11em
Created May 9, 2012 08:27
Show Gist options
  • Save 6ui11em/2642954 to your computer and use it in GitHub Desktop.
Save 6ui11em/2642954 to your computer and use it in GitHub Desktop.
jQuery: Fancybox dialog / alert
function fancyAlert(msg) {
jQuery.fancybox({
'modal' : true,
'content' : "<div style=\"margin:1px;width:240px;\">"+msg+"<div style=\"text-align:right;margin-top:10px;\"><input style=\"margin:3px;padding:0px;\" type=\"button\" onclick=\"jQuery.fancybox.close();\" value=\"Ok\"></div></div>"
});
}
function fancyConfirm(msg,callback) {
var ret;
jQuery.fancybox({
modal : true,
content : "<div style=\"margin:1px;width:240px;\">"+msg+"<div style=\"text-align:right;margin-top:10px;\"><input id=\"fancyConfirm_cancel\" style=\"margin:3px;padding:0px;\" type=\"button\" value=\"Cancel\"><input id=\"fancyConfirm_ok\" style=\"margin:3px;padding:0px;\" type=\"button\" value=\"Ok\"></div></div>",
onComplete : function() {
jQuery("#fancyConfirm_cancel").click(function() {
ret = false;
jQuery.fancybox.close();
})
jQuery("#fancyConfirm_ok").click(function() {
ret = true;
jQuery.fancybox.close();
})
},
onClosed : function() {
if (typeof callback == 'function'){ callback.call(this, ret); }
}
});
}
function fancyConfirm_text() {
fancyConfirm("Ceci est un test", function(ret) {
alert(ret)
})
}
@emacaste
Copy link

emacaste commented Dec 5, 2014

Thx (y)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment