使用jquery加载内容后,不会使用Javascript文件

时间:2016-09-01 19:10:52

标签: jquery html ajax

我想在模式中加载内容,它运行良好,但加载内容后没有显示javascript文件。这是我的代码:

index.html.twig 。                            

这是 ajax_backend.js 中加载内容的功能:

$(document).on('show.bs.modal', "#myModal", function (e) {
    // load content inside modal from the link
    var link = $(e.relatedTarget);
    showLoadingDiv();

    $(this).load(link.attr("href"), function (responseTxt, statusTxt, xhr) {
        if (statusTxt == "success") {
            collectionInsideModal();
            hideLoadingDiv();
        }
        if (statusTxt == "error")
            alert("Erreur: " + xhr.status + ": " + xhr.statusText);
        hideLoadingDiv();
    });

    $(this).on("hidden.bs.modal", function () {
        $(this).html('');
    });
});

加载内容后,文件 nifty.min.js 未显示,因此我必须使用如下内容重新加载此文件:

 <div>
 // content that will be loaded
 </div>
 <script src="{{ asset('backend/js/nifty.min.js') }}"></script>

如何修复它以避免每次都重新加载包含内容的JS文件?

这是文件nifty.min.js未缩小

0 个答案:

没有答案