【问题标题】:Bootstrap Modal Does Not Appear When Bootstrap-Transition.js IS included包含 Bootstrap-Transition.js 时不出现 Bootstrap 模态
【发布时间】:2013-06-28 17:57:24
【问题描述】:

我在我的 rails 应用程序中使用 Thomas McDonals 的 bootstrap-sass gem,每当我包含 bootstrap-transition.js 时,我的模态弹出窗口就不再出现。背景淡入,但实际的模态窗口不会出现。它甚至没有在源代码中显示,所以它不仅仅是被隐藏了。当我删除 bootstrap-transition.js 文件时,模式会正常工作。

现在,我包含了所有 bootstrap.js 文件,所以我正在做的事情没有什么不寻常的。

有人对如何恢复该模式有任何建议吗?我需要我正在使用的轮播的过渡。

编辑:为清楚起见,我没有手动添加引导 js 文件,我只是按照 bootstrap-sass gem 的指示将它们包含在我的应用程序的 application.js 文件中。但是,开箱即用,模式窗口不起作用。

【问题讨论】:

    标签: javascript ruby-on-rails twitter-bootstrap bootstrap-sass


    【解决方案1】:

    你为什么要添加 Js 文件? gem 应该通过资产管道将它们引入,您只需要将它们导入到您的 Js 的 application.js 文件中,并为引导 css 创建一个 css.scss 文件,如下所示:

    boot.css.scss:

    $navbarBackground: #000;
    $navbarText: #fff;
    $navbarLinkColor: #888;
    $navbarBrandColor: #FFF;
    
    @import "bootstrap";
    @import "bootstrap-responsive";
    

    application.js:

    // This is a manifest file that'll be compiled into application.js, which will include all the files
    // listed below.
    //
    // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
    // or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
    //
    // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
    // the compiled file.
    //
    // WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
    // GO AFTER THE REQUIRES BELOW.
    //
    //= require jquery
    //= require jquery_ujs
    //= require bootstrap
    //= require_tree .
    

    【讨论】:

    • 如果我不清楚,我深表歉意。当我写“包括 js 文件”时,我的意思是将它们添加到 application.js。所以,我正在做你所描述的。然而,该模式不起作用。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-11-07
    • 2023-01-22
    • 1970-01-01
    相关资源
    最近更新 更多