无法让 bootstrap-modal.js 在 Rails 中工作 [英] Can't get bootstrap-modal.js to work in Rails

查看:29
本文介绍了无法让 bootstrap-modal.js 在 Rails 中工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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

在 Rails 中使用完全相同的代码,当我点击时没有任何反应.

我在视图中设置了这个 html

Demo

<!-- 模态内容示例--><div id="modal-from-dom" class="modal hidefade"><div class="modal-header"><a href="#" class="close">&times;</a><h3>模态标题</h3>

<div class="modal-body"><p>一个精致的身体……</p>

<div class="modal-footer"><a href="#" class="btn primary">Primary</a><a href="#" class="btn secondary">Secondary</a>

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

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

在 Rails 中,

但是当我在 Rails 应用程序中点击启动时什么也没有发生

解决方案

= javascript_include_tag "application"

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

I'm trying to get bootstrap-modal.js to work in Rails but can't figure it out. At this point, I'm just trying to get the event to fire when I click the button as in this fiddle

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

using the exact same code in Rails nothing's happening when I click.

I have this html set up in a view

<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>

And bootstrap-modal.js copied into the javascripts folder in the assets pipeline

In Rails,

But nothing's happening when I click launch in my rails application

解决方案

= javascript_include_tag "application"

wasn't in the application layout so bootstrap-modal.js also wasn't included. problem now solved.

这篇关于无法让 bootstrap-modal.js 在 Rails 中工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
其他开发最新文章
热门教程
热门工具
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆