【问题标题】:Rails 3.x Assets Pipeline Facebox jQuery Plugin (how to set up)Rails 3.x Assets Pipeline Facebox jQuery 插件(如何设置)
【发布时间】:2012-06-23 04:07:04
【问题描述】:

我整晚都在用头撞墙,试图弄清楚为什么 jQuery Facebox 插件无法在我的 Rails 应用程序中运行。这是我遇到的错误,从 doc ready 中调用它:

$.facebox("<a href='#'>hello</a>");

我感觉这与资产管道有关,但不确定。这就是我设置所需文件的方式:

vendor/assets/images/facebox/
./loading.gif
./closelabel.png

vender/assets/javascripts/facebox/
./facebox.js

vender/assets/stylesheets/facebox/
./facebox.css

然后在我的 application.css

...
*= require_self
 *= require_tree .
 *= require_tree ../../../vendor/assets/stylesheets/.
...

然后在我的 application.js

...
//= require jquery
//= require jquery_ujs
//= require_tree ../../../vendor/assets/javascripts/.
//= require_tree .
...

抛出这个 javascript 错误:

TypeError: Object function ( selector, context ) {// The jQuery object is actually just the init constructor 'enhanced'return new jQuery.fn.init( selector, context );} has no method 'facebox'

【问题讨论】:

    标签: javascript jquery ruby-on-rails-3 asset-pipeline facebox


    【解决方案1】:

    只需使用facebox-rails gem,您的生活就会大大改善。

    因为这花了我 2 小时的挫败感试图弄清楚,所以我想我会发布我的解决方案,这花了我 2 分钟的时间来设置。

    我也非常喜欢将其放入 gem 中的解决方案,因为您不必经历将所有文件拆分并确保将它们放置在正确位置并配置路径的痛苦。因为我在我所有的项目中都使用了这个弹出窗口,所以它真的出现在 andy 中。说真的,感谢制作这颗宝石的人!

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-01-29
      • 1970-01-01
      • 1970-01-01
      • 2015-12-18
      • 1970-01-01
      相关资源
      最近更新 更多