Tuesday, December 1, 2009

Close a JQuery Dialog by clicking outside of it

Thank you David Little: http://www.littled.net/new/2009/11/30/how-to-close-a-jquery-dialog-box-by-clicking-outside-of-it/

function show_dialog(title, content) {
// close dialog when clicking outside of it
$(".ui-widget-overlay").live("click", function() { $("#mydialog").dialog("close"); } );
$("#mydialog").html(content);
$('#mydialog').dialog('option', 'title', title);
$("#mydialog").dialog( {
modal : true,
autoOpen : false,
title : title,
position: 'left'
});

No comments: