【问题标题】:Can't get bootstrap-modal.js to work in Rails无法让 bootstrap-modal.js 在 Rails 中工作
【发布时间】:2011-12-26 09:26:38
【问题描述】:

我正在尝试让 bootstrap-modal.js 在 Rails 中工作,但无法弄清楚。此时,我只是想在单击此小提琴中的按钮时触发事件

http://jsfiddle.net/mjmitche/xt4aQ/16/

在我单击时在 Rails 中使用完全相同的代码没有任何反应。

我在视图中设置了这个 html

<h3>Demo</h3>
          <!-- sample modal content -->
          <div id="modal-from-dom" class="modal hide fade">
            <div class="modal-header">
              <a href="#" class="close">&times;</a>
              <h3>Modal Heading</h3>
            </div>
            <div class="modal-body">
              <p>One fine body…</p>
            </div>
            <div class="modal-footer">
              <a href="#" class="btn primary">Primary</a>
              <a href="#" class="btn secondary">Secondary</a>
            </div>
          </div>

<button data-controls-modal="modal-from-dom" data-backdrop="true" data-keyboard="true" class="btn danger">Launch Modal</button>

并将bootstrap-modal.js复制到资产管道中的javascripts文件夹中

在 Rails 中,

但是当我在我的 rails 应用程序中单击启动时什么都没有发生

【问题讨论】:

  • 试试这个:jsfiddle.net/xt4aQ/21
  • 仍然没有工作,我认为这与代码如何包含在我的 rails 应用程序中有关。我单击 Firebug 中的按钮,但没有任何反应。没有错误信息
  • = javascript_include_tag "application" 不在布局中。问题解决了。

标签: ruby-on-rails twitter-bootstrap


【解决方案1】:
= javascript_include_tag "application"

不在应用程序布局中,因此 bootstrap-modal.js 也不包括在内。问题现在解决了。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2017-07-13
    • 2019-01-12
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多