【发布时间】:2015-09-12 09:32:55
【问题描述】:
我正在尝试使用 Rails 4 完成教程 Blueimp Gallery (gem 'blueimp-gallery'),当我点击照片时不会收取费用。
我的应用程序.js
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require bootstrap-sprockets
//= require blueimp-gallery-all
//= require_tree .
我想问一下@import "blueimp-gallery-all";是否更好
或者是否可以在我的 custom.css.sccs 文件中工作,因为我使用的是 Sass,并且我在其他配置中看到他们建议这样做。不同于教程!
然后在我的 application.css.scss 中:
*= require_tree .
*= require_self
*= require blueimp-gallery-all
然后在我生成一个控制器库:
class GalleryController < ApplicationController
def lightbox
end
def caroussel
end
end
在我看来,我这样做:
在 lightbox.html.erb 中
<h1>Gallery</h1>
<div id="blueimp-gallery" class="blueimp-gallery">
<div class="slides"></div>
<h3 class="title"></h3>
<a class="prev">‹</a>
<a class="next">›</a>
<a class="close">×</a>
<a class="play-pause"></a>
<ol class="indicator"></ol>
</div>
<div id="links">
<%= link_to image_tag("imgJatinho.jpg", :alt => "Rodrigo Batera1", height: '110', width: '110' ) %>
<%= link_to image_tag("image2.jpg", :alt => "Rodrigo Batera2", height: '110', width: '110') %>
<%= link_to image_tag("image3.jpg", :alt => "Rodrigo Batera3", height: '110', width: '110') %>
</div>
<script>
document.getElementById('links').onclick = function (event) {
event = event || window.event;
var target = event.target || event.srcElement,
link = target.src ? target.parentNode : target,
options = {index: link, event: event},
links = this.getElementsByTagName('a');
blueimp.Gallery(links, options);
};
</script>
文件视图 carousel.html.erb
<div id="blueimp-gallery-carousel" class="blueimp-gallery blueimp-gallery-carousel">
<div class="slides"></div>
<h3 class="title"></h3>
<a class="prev">‹</a>
<a class="next">›</a>
<a class="play-pause"></a>
<ol class="indicator"></ol>
</div>
<div id="links">
<a href="imgJatinho.jpg" title="Banana" data-gallery>
<img src="imgJatinho.jpg" alt="Banana">
</a>
<%= link_to image_tag("imgJatinho.jpg", :alt => "Rodrigo Batera1", height: '110', width: '110')%>
<%= link_to image_tag("image2.jpg", :alt => "Rodrigo Batera2", height: '110', width: '110') %>
<%= link_to image_tag("image3.jpg", :alt => "Rodrigo Batera3", height: '110', width: '110') %>
</div>
<script>
blueimp.Gallery(
document.getElementById('links').getElementsByTagName('a'),
{
container: '#blueimp-gallery-carousel',
carousel: true
}
);
</script>
还有一件事我想问一下如果我使用咖啡脚本的方式,文件.coffee 的名称将如何?我将每个代码都放在文件gallery.coffee 中(我尝试过但不起作用)?
【问题讨论】:
标签: javascript ruby-on-rails-4 coffeescript blueimp bootstrap-sass