如果采用的是bootstrap2.0则采用如下代码解决:
$("#myModal").on("hidden", function() {
$(this).removeData("modal");
});
如果采用的是bootstrap3.0则采用以下几种代码解决:
首选方法
//刷新模态框数据,首选这两种方法,不会出现加载延迟的问题,比较流畅
方法一:
$(document).on("hidden.bs.modal", function (e) {
$(e.target).removeData("bs.modal").find(".modal-content").empty();
});
方法二:
$(document).on("hidden.bs.modal", ".modal:not(.local-modal)", function (e) {
$(e.target).removeData("bs.modal").find(".modal-content").empty();
});
其次方法
//刷新模态框数据,这两种方法其次,会出现加载延迟的问题
方法一:
$("#ajax").on("hidden.bs.modal", function () {
$(this).removeData("bs.modal");
});
方法二:
$('body').on('hidden.bs.modal', '.modal', function () {
$(this).removeData('bs.modal');
});