我的模态对话框完美地工作(也就是说,我可以调整每个选项),只是按钮图标选项没有效果。这是我用来生成对话框的代码:
$('#alert_div')
.attr("title", "Delete all instances?")
.text("Are you sure you want to delete all instances of this event between the specificed dates? This cannot be undone.")
.dialog({
modal: true,
draggable: false,
position: { my: "top", at: "center", of: window },
buttons: [
{
text: "No",
icons: { primary: "ui-icon-check" },
click: function() {
$(this).dialog('close');
console.log('Clicked no.');
}
},
{
text: "Yes",
click: function () {
$(this).dialog('close');
console.log('Clicked yes');
}
}
]
});
我已经查看了所有相关的 Stack Overflow 问题,例如这个。除了在打开时将元素附加到按钮上,我不知道如何解决这个问题。当我在文档的其他位置创建元素并给它们正确的类时,图标会显示出来。
以下是 jQuery 在打开对话框时生成的按钮 HTML:
<div class="ui-dialog-buttonset"><button type="button" icons="[object Object]" class="ui-button ui-corner-all ui-widget">OK</button></div>
我认为在图标属性中应该有除了'[object Object]'之外的其他内容。这是为什么?我正在使用jQuery UI v.1.12.0和jQuery v.3.0.0,而且我没有使用Bootstrap。