我有一个针对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>
答案 0 :(得分:0)
我通过简单地将渲染和脚本链接移至标头并将JS脚本移至正文来解决了我的问题。