我是否可以只重新加载引导程序模式,而不必执行location.reload()?

问题描述 投票:0回答:1

我想在其隐藏事件上重新加载引导程序模式,因此稍后打开它时,它将再次执行我的所有js函数。如果我执行location.reload,它就可以工作,但是必须等待页面重新加载才能使我再次打开模态,这有点烦人。有什么解决方案吗?

javascript jquery twitter-bootstrap
1个回答
0
投票

您可以使用jQuery Ajax来获取模型的数据。

$('#myModal').on('hidden.bs.modal', function () { //modal hidden event
    $.ajax({
        url: "data.json",
        success: function(result){
            $('#myModal').html(result); //set new data to modal
            $('#myModal').modal('show'); //show the modal
        }
    });
});

Bootstrap 3和4的模式事件

[Bootstrap 4Bootstrap 3

© www.soinside.com 2019 - 2024. All rights reserved.