我想使用intercooler.js将内容加载到Bootstrap 4模式中

时间:2019-10-12 00:36:08

标签: javascript ajax bootstrap-4

我正在尝试使用中冷器将内容加载到模态中,例如:

http://jsfiddle.net/qvpy3coL/3/

我不高兴,不知道这是否可能,或者引导js是否会冲突?

HTML是:

<div id="confirm-me" class="btn btn-primary" data-toggle="modal" 
    data-target="#msgmodal" ic-get-from="/click" ic-target="dynamiccontent"
    ic-trigger="click">
    Click Me to show dynamic modal</div>

<div class="modal fade" id="msgmodal">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                 <h4 class="modal-title">
                 Below will be dynamic content</h4>
            </div>

            <div id="dynamiccontent">
            </div>
        </div>
    </div>
</div>

js是:

// mockjax stuff ...
$.mockjax({
    url: "/click",
    responseTime: 500,
    response: function (settings) {
        this.responseText = "Dynamic stuff here!";
    }
});

1 个答案:

答案 0 :(得分:1)

我从没使用过中冷器,但快速阅读后发现应该没问题。

您需要在模式中包含动态内容的唯一要求是它应该是有效的HTML代码。

我处理了您在其中添加一些内容的示例:

$('#dynamiccontent').html('No, it wont have any problems as long as your placing HTML')

https://jsfiddle.net/5pe6yz0w/3/