无法从close上删除模态。每次都显示相同的内容

无法从close上删除模态。每次都显示相同的内容

$('body').on('hidden.bs.modal', '.modal', function () { $(this).removeData('bs.modal'); }); 

此function也无效。

有同样的问题,当我将数据传递给相同的模态,并删除内容。 最好的解决方案,只有使用bootBox

http://bootboxjs.com/

 bootbox.dialog({ message: "I am a custom dialog", title: "Custom title", buttons: { success: { label: "Success!", className: "btn-success", callback: function() { Example.show("great success"); } }, danger: { label: "Danger!", className: "btn-danger", callback: function() { Example.show("uh oh, look out!"); } }, main: { label: "Click ME!", className: "btn-primary", callback: function() { Example.show("Primary button"); } } } }); 

以这种方式尝试Bootstrap v3.2.0

 $(document).on("hidden.bs.modal", function (e) { $(e.target).removeData("bs.modal").find(".modal-content").empty(); }); 

通用模态的例子

  

男人,我终于可以做出工作了

应该是。

  $('body').on('hide.bs.modal', '.modal', function (e) { $(this).find('form').trigger("reset"); }); 

在这篇文章中我无法从bootstrap模式中清除表单数据 Sadikhasan用户钉它,你需要清除表单数据但$(this)是模态div,所以你需要在模态中找到表单并重置它。