Close dialog on click (anywhere)

前端 未结 10 1107
旧时难觅i
旧时难觅i 2020-11-30 23:34

Is there a default option to close a jQuery dialog by clicking somewhere on the screen instead of the close icon?

10条回答
  •  [愿得一人]
    2020-12-01 00:20

    In some cases, Jason's answer is overkill. And $('.ui-widget-overlay').click(function(){ $("#dialog").dialog("close"); }); doesn't always work with dynamic content.

    The solution that I find works in all cases is:

    $('body').on('click','.ui-widget-overlay',function(){ $('#dialog').dialog('close'); });
    

提交回复
热议问题