我正在嘗試使用Rails 4來編寫教程Blueimp Gallery (gem 'blueimp-gallery'),並且在點擊它們時不收取照片。如何在Rails 4中配置blueimp-gallery
我的application.js
//= require jquery
//= require jquery_ujs
//= require turbolinks
//= require bootstrap-sprockets
//= require blueimp-gallery-all
//= require_tree .
我想問問,如果是好做@import "blueimp-gallery-all";
或者如果因我的custom.css.sccs文件工作,因爲我使用無禮,我在看到其他他們推薦的配置做這個。不同的教程!
然後在我的application.css.scss:
*= require_tree .
*= require_self
*= require blueimp-gallery-all
然後我產生控制器畫廊:
class GalleryController < ApplicationController
def lightbox
end
def caroussel
end
end
,在我的觀點我這樣做:
在燈箱.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>
文件視圖caroussel.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>
與其他的事情我想問如果我使用coffescript方式如何將文件.coffee的名字嗎?我把每個代碼放在文件gallery.coffee中(我嘗試過並且不行)?