【发布时间】:2017-08-13 03:20:59
【问题描述】:
我有一个 jquery 模态对话框,它在函数中创建如下:
function EditDialog(pk) {
$.ajax({
url: "{% url 'populatereviewform' %}",
method: 'GET',
data: {
pk: pk
},
success: function(formHtml){
//place the populated form HTML in the modal body
$('.modal-body').html(formHtml);
$( "#dialog" ).modal({width: 500, height: 500});
},
dataType: 'html'
});
return false;
}
如何确保每次调用此函数时都会创建一个新的对话框实例?我想知道我是否可以以某种方式挂钩关闭事件并确保对话框被完全破坏。我正在尝试调试某些东西,似乎我的某些变量在第二次调用此对话框时没有刷新,我正试图深入了解它。创建对话框的django模板为:
<div id="dialog" class="modal" title="Edit" style="display:none">
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">×</span></button>
<h4 class="modal-title">Review Uploaded Image</h4>
</div>
<div class="modal-body">
</div>
</div>
</div>
</div>
【问题讨论】:
-
你在使用引导模式吗?
-
$(".modal").on("hidden.bs.modal", function(){ //your variables here }); -
是的,很抱歉回复晚了。我的互联网死了!
标签: javascript jquery django django-templates