jquery - Bootstrap 模式不只显示在我的机器上

标签 jquery twitter-bootstrap asp.net-core-mvc

我的问题很容易理解: Bootstrap 模式在应该显示的时候没有显示。 如下图所示,网站全部变灰,但不显示模式。有趣的是,这种情况只发生在我的机器上。我尝试过使用 Firefox、Chrome、Edge,也尝试过隐身模式,但似乎没有任何效果。然而,这适用于其他人的机器,包括我自己的另一台机器。 编辑:我尝试清除缓存并使用开发工具中使用“无缓存”的选项。依然没有。 AJAX 请求返回 200,并且我可以看到代码中注入(inject)的模式 HTML,所以我认为它工作正常。 Modal not working

使用开发工具仔细查看 CSS,似乎 .modal 类仍然具有 display:none 属性,当我将其取消时,我可以看到模态。但我不必手动执行此操作...

这是当您按下加号按钮时触发的 JavaScript:

    Start: function (id) {
    $.ajax({
        url: "/Progetti/ElencoProgetti/Create/", //this is the location of the modal
        data: {
            id: (id == null ? 0 : id),
        },
        success: function (data) {
            if (id == 0) {
                $("#nuovoProgettoLabel").html("Aggiungi progetto");
            } else {
                $("#nuovoProgettoLabel").html("Modifica progetto");
            }
            $("#nuovoProgettoBody").html(data);
            //NuovoProgetto.Init();
            $("#nuovoProgetto").modal('show');
        },
        error: function () {
            Swal.fire(
                'Evento',
                'Errore durante il caricamento',
                'error'
            );
        }
    });

这是模态框所在的 HTML:

<div class="modal fade" id="nuovoProgetto" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg" role="document">
    <div class="modal-content">
        <div class="modal-header">
            <h4 class="title" id="nuovoProgettoLabel">Evento</h4>
        </div>
        <div class="modal-body" id="nuovoProgettoBody"> 
        <!-- the JS injects the modal here-->
        </div>
        @*<div class="modal-footer">
                <button type="button" class="btn btn-primary">SAVE CHANGES</button>
                <button type="button" class="btn btn-danger" data-dismiss="modal">CLOSE</button>
            </div>*@
    </div>
</div>

很确定 JQuery 版本是 331。不太确定 bootstrap 版本(高级版本说主要版本是 4) 我对 SO 还很陌生,所以如果您需要其他任何信息,请告诉我。我很茫然......尽管我已经为您提供了我认为足够的代码来理解这一点,但您可能无法重现该问题,因为它只发生在我的笔记本电脑上。 关于什么可能导致这种情况的任何线索?

最佳答案

导致此问题的一个可能原因是相关计算机在可访问性下“尽可能关闭所有必要的动画”。有关更多详细信息,请参阅此堆栈溢出问题。我就是这种情况。 Bootstrap modal: class="modal fade" causing problems

关于jquery - Bootstrap 模式不只显示在我的机器上,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62266093/

相关文章:

jquery - 如何从全局范围内调用 jquery 函数内的方法?

javascript - 选中复选框时动态更改 Bootstrap 进度条值

url-rewriting - ASP.NET Core 1.1 Url 重写 - www 到非 www

c# - .Net Core ActionResult<bool> 总是返回 false?

javascript - 如何在没有 jQuery 的情况下在 div 之间平滑滚动

jquery - 单选按钮切换功能

jQuery 事件没有持续触发

jquery - Bootstrap Select-Picker 防止关闭

php - 将 Bootstrap 模式部分 View 动态插入 View 中

Asp.net 5 MVC 6, 为 facebook 电子邮件添加权限