Close dialog on click (anywhere)

前端 未结 10 1168
旧时难觅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:00

    When creating a JQuery Dialog window, JQuery inserts a ui-widget-overlay class. If you bind a click function to that class to close the dialog, it should provide the functionality you are looking for.

    Code will be something like this (untested):

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

    Edit: The following has been tested for Kendo as well:

    $('.k-overlay').click(function () {
                var popup = $("#dialogId").data("kendoWindow");
                if (popup)
                    popup.close();
            });
    

提交回复
热议问题