簡體   English   中英

jQuery對話框上的關閉按鈕

[英]Close button on Jquery Dialog

我有一個針對jquery-ui的自定義警報ui設置,但由於某種原因,我的關閉按鈕無法關閉窗口。 下面是我的代碼。 我正在嘗試使用此鏈接中提到的jQuery UI的override alert()。 任何幫助表示贊賞。 https://andrewensley.com/2012/07/override-alert-with-jquery-ui-dialog/

<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<link rel="stylesheet" href="//code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css">
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<script type ="text/javascript">
    window.alert = function (message) {
        $(document.createElement('div'))
            .attr({ title: 'Invoice Information', 'class': 'alert' })
            .html(message)
            .dialog({
                draggable: true,
                modal: true,
                resizable: false,
                width: 'auto',
                buttons: {
                    OK: function () {
                        $(this).dialog("close");
                    }
                },
                close: function () { $(this).remove();}
            });
    };
</script>

我只需將渲染器和腳本鏈接移動到標題中,然后將JS腳本移動到正文中,即可解決問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM