almost 4 years ago

系統:

Mac OS X Yosemite 10.10.1
Ruby 2.1.5
Rails 4.1.8

相關連結

fancyBox2 ( http://fancyapps.com/fancybox/ )
fancybox2-rails ( https://github.com/kyparn/fancybox2-rails )

設定步驟如下

1. Gemfile 設定

添加必要的 gem 套件至 Gemfile 檔中

# Use fancyBox2
gem 'fancybox2-rails'
$ bundle install

2. assets 設定

app/assets/javascripts/application.js

//= require jquery
...
//= require fancybox
...
//= require_tree .

app/assets/stylesheets/application.css.scss

 *= require_tree .
 ...
 *= require fancybox
 ...
 *= require_self

app/assets/javascripts/base.js.coffee

$ ->
  # use fancyBox2
  $('.fancybox').fancybox();

3. views 設定

使用方法
<%= link_to image_tag('img_url'), 'img_url', class: 'fancybox' %>
← Devise - part 4 - Add Identity Validator Post 管理 - part 1 - 基本設定 →
 
comments powered by Disqus