【发布时间】:2020-06-06 02:16:57
【问题描述】:
我正在使用带有 Bootstrap 的 Django 2.2。
这是用于
的approach- 打开一个模态窗口,
- 用户更新数据,
- 用户保存
- 更新打开窗口的基础表并关闭模式窗口
到目前为止,一切正常,但是,当您单击相同的按钮打开窗口时会出现问题。在这里,当您单击按钮时,什么也没有发生!
这是 javascript 文件。
$("#modal-risk-profile").on("submit", ".form-risk-profile", function () {
var form = $(this);
$.ajax({
url:form.attr("action"),
data:form.serialize(),
type:form.attr("method"),
dataType:'json',
success: function(data) {
console.log(data.form_is_valid);
if(data.form_is_valid) {
console.log(data.html_planner_client_list);
$("#id_client_table tbody").html(data.html_planner_client_list); // if you remove this line, modal window appears without any issues
$("#modal-risk-profile").modal("hide");
console.log("I have returned with success");
}
else {
console.log("I am in else");
$("#modal-risk-profile .modal-content").html(html_form);
}
}
});
return false;
});
html_planner_client_list的输出如下:
<tr>
<td> Rajesh </td>
<td> 01-04-2000 </td>
<td> Bangalore </td>
<td> ramachandran.test@gmail.com </td>
<td> Salaried </td>
<td class="text-center">
<button class="button-risk-profile btn btn-danger btn-sm py-0" style="font-size:0.9em" data-url="/client/riskprofileplanner/19/">
Take Questionnaire
</button>
</td>
<td> Subramanian</td>
<td class="text-left">
<a href="/client/client_select/19/" class="btn btn-primary btn-sm py-0" style="font-size: 0.9em;">Select </a>
<a href="/client/client_edit/19/" class="btn btn-primary btn-sm py-0" style="font-size: 0.9em;">Edit </a>
<a href="/client/client_report/19/" class="btn btn-primary btn-sm py-0" style="font-size: 0.9em;">Report </a>
<button class="button-choose-planner btn btn-primary btn-sm py-0" style="font-size: 0.9em;" data-url="/client/select_planner/19/">
Planner
</button>
</td>
Inspector Log 中没有错误,Django 中也没有错误。
可能会出什么问题?
【问题讨论】:
标签: javascript django ajax modal-dialog