【问题标题】:Bootstrap Modal Plugin Loading Not DisplayingBootstrap 模态插件加载不显示
【发布时间】:2013-08-26 08:24:27
【问题描述】:

我已经绞尽脑汁好几个小时了,但我不明白为什么 bootstrap modal 在使用 ajax 功能时不会从 .on 事件中显示加载屏幕。 $('body').modalmanager('loading');如果我把它放在 .on 事件之外就可以工作,所以我知道脚本工作正常。但是当它在 on 事件中时,就像在插件示例中一样,我什么也得不到。有什么建议吗?

我正在使用下面的代码绑定一个点击事件:

    $.fn.modalmanager.defaults.resize = true;
    $.fn.modalmanager.defaults.spinner = '<div class="loading-spinner fade" style="width: 200px; margin-left: -100px;"><img src="http://localhost:2621/assets/img/ajax-modal-loading.gif" align="middle">&nbsp;<span style="font-weight:300; color: #eee; font-size: 18px; font-family:Open Sans;">&nbsp;Loading...</div>';

var $modal = $('#add-offense');

$('.add-offense-btn').on('click', function () {
    // create the backdrop and wait for next modal to be triggered
    // THIS IS NEVER CALLED INSIDE THE .on EVENT
    $('body').modalmanager('loading');

    var url = "/case/saveoffense/"; // the url to the controller

    setTimeout(function () {
        $modal.load(url, '', function () {

            $modal.modal().on("hidden", function () {
                $modal.empty();
            });
            $modal.modal();
        })
    }, 1000);
});

除了 bootstrap.js,我还包括了最新的 bootstrap-modal 文件,如下所示:

<script src="@Url.Content("~/assets/plugins/bootstrap-modal/js/bootstrap-modal.js")" type="text/javascript" ></script>
<script src="@Url.Content("~/assets/plugins/bootstrap-modal/js/bootstrap-modalmanager.js")" type="text/javascript" ></script>

【问题讨论】:

  • 有机会把它扔到 jsbin 上吗?
  • 不幸的是,我无法粘贴确切的 js 代码。我发现正在制作 $('body').modalmanager('loading') ,但即使使用插件演示中的确切代码,加载功能也会失败。我猜我有 id 或 css 类冲突?

标签: jquery twitter-bootstrap bootstrap-modal


【解决方案1】:

查看a标签;使用而不是 href=''

【讨论】:

    猜你喜欢
    • 2018-01-03
    • 1970-01-01
    • 1970-01-01
    • 2016-04-06
    • 2019-07-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多