美文网首页我爱编程
bootstrap 模态框之remote

bootstrap 模态框之remote

作者: 秃头大叔 | 来源:发表于2018-02-23 17:03 被阅读0次

在使用bootstrap模态框加载外面页面时,首次加载后,页面缓存无法更新

//使用方法
$("#myModal").modal({
    remote: "table.html"
});
尝试的解决方案
//bootstrap v2 
$("#myModal").on("hidden", function() {
    $(this).removeData("modal");
});
//bootstrap v3
$("#myModal").on("hidden.bs.modal", function() {
    $(this).removeData("bs.modal");
});

项目中用的v3.3.7 结果均无效

最后找到如下解决办法

//modal初始化和打开之前清除页面内容和缓存数据
$('#myModal .modal-content').empty();
$('#myModal').removeData('bs.modal').modal({
    remote: "xxx"
});

相关文章

网友评论

    本文标题:bootstrap 模态框之remote

    本文链接:https://www.haomeiwen.com/subject/edbxxftx.html