我整晚都在用头撞墙,试图弄清楚为什么 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'