Return to Snippet

Revision: 31074
at August 28, 2010 20:47 by joernroeder


Initial Code
/**
 * 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));
}

Initial URL

                                

Initial Description

                                

Initial Title
confirm() to jQuery UI Dialog

Initial Tags
jquery

Initial Language
JavaScript