/ Published in: JavaScript
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
/** * Override javascript confirm() and wrap it into a jQuery-UI Dialog box * * @depends $.getOrCreateDialog * * @param { String } the alert message * @param { String/Object } the confirm callback * @param { Object } jQuery Dialog box options */ function confirm(message, callback, options) { var defaults = { modal : true, resizable : false, buttons : { Ok: function() { $(this).dialog('close'); return (typeof callback == 'string') ? window.location.href = callback : callback(); }, Cancel: function() { $(this).dialog('close'); return false; } }, show : 'fade', hide : 'fade', minHeight : 50, dialogClass : 'modal-shadow' } $confirm = $.getOrCreateDialog('confirm'); // set message $("p", $confirm).html(message); // init dialog $confirm.dialog($.extend({}, defaults, options)); }