I initiate a jQuery modal window from a button click and would like it to close when I click somewhere outside the dialog. Does anyone know how to achieve that?
This is how the dialog is created:
var $dial2 = ""
    function openmenu(width, height, menuID){ if ($dial2 == "") {
        $dial2 = $('<div></div>')
                       .html('<iframe id="dial2" style="border: 0px; " src=/CustomControls/PageSubMenu.aspx?&menuID="' + menuID + '" width="100%" height="100%"></iframe>')
                       .dialog({
                           autoOpen: false,
                           modal: false,
                           height: height,
                           width: width,
                           title: 'Menu',
                           draggable: false,
                           resizable: false,
                           position: {
                               my: 'top',
                               at: 'left-207',
                               of: $('#btnMenu')
                           },
                           dialogClass: "testdia"
                       });
        $dial2.dialog('open');
    }
}
Just to let you know I have tried the options (2 x for non modal) that are displayed in posts on stackoverflow and they don't work which is why I am posting this. I guess it is something to do with the iframe etc. so it is a special case.
 
     
    