您好,当在模态对话框上单击关闭按钮时,我需要重新加载父页面。 我的代码是:
//customer edit start
$( ".modal-customeredit" ).click(function() {
var myGroupId = $(this).attr('data-id'); // data-id
$.post("sample.php",
{
name:myGroupId,
},
function(data,status){
});
$( "#modal-customeredit" ).dialog({
modal: true,
minWidth: 700,
minHeight: 200,
dialogClass: "modal-dialog",
show: "fadeIn"
});
$('.ui-widget-overlay').addClass('bg-black opacity-60');
});
我尝试关闭按钮为/
$( ".ui-dialog-titlebar-close" ).click(function() {
window.location.reload(true);
});
在下面也试过里面。没有任何效果。任何人都可以帮助我。谢谢。
最佳答案
您可以使用对话的原生 create
事件来绑定(bind)关闭按钮点击。像这样:
$( "#modal-customeredit" ).dialog({
modal: true,
minWidth: 700,
minHeight: 200,
dialogClass: "modal-dialog",
show: "fadeIn",
create: function() {
$(this).closest('div.ui-dialog')
.find('a.ui-dialog-titlebar-close')
.click(function(e) {
window.location.reload(true);
e.preventDefault();
});}
});
关于javascript - 如何为这个脚本 jquery 绑定(bind)关闭事件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22382139/