我想在用户按下按钮关闭对话框时收到通知。我尝试了以下但是它没有工作:
<div id="TestDialog"/>
$("#TestDialog").dialog({
autoOpen: true,
resizable: true,
modal: true,
position: ['middle', 'middle'],
savePushed: function() {
alert('save pushed');
},
closePushed: function() {
alert('save pushed');
},
buttons: {
"Save": function() {
// alert('save');
savePushed();
$(this).dialog("close");
},
Close: function() {
//alert('close');
closePushed();
$(this).dialog("close");
}
}
});
还有其他想法吗?
答案 0 :(得分:1)
您必须正确定义savePushed()
和closePushed()
功能。由于它们不是Jquery-UI Dialog的一部分,因此您无法将其设置为选项。
将代码重写为:
$("#TestDialog").dialog({
autoOpen: true,
resizable: true,
modal: true,
position: ['middle', 'middle'],
buttons: {
"Save": function() {
alert('Save button was pressed!');
$(this).dialog("close");
},
"Close": function() {
alert('Close button was pressed!');
$(this).dialog("close");
}
}
});
savePushed()
或closePushed()
,当用户按下按钮时,您可以重写代码:
function savePushed() {
alert('Save button was pressed!');
}
function closePushed() {
alert('Save button was pressed!');
}
$("#TestDialog").dialog({
autoOpen: true,
resizable: true,
modal: true,
position: ['middle', 'middle'],
buttons: {
"Save": function() {
savePushed();
$(this).dialog("close");
},
"Close": function() {
closePushed();
$(this).dialog("close");
}
}
});