2010-10-20 15 views
0

我試圖做一個簡單的測試與facebox_render和軌道3軌道/ facebox_render - 阿賈克斯沒有定義(facebox總是加載...)

這裏是我的步驟:

1)安裝的Jquery 1.4.2(Jrails)

2.)插件安裝 軌道插件安裝GIT中://github.com/ihower/facebox_render.git

3。),並添加下列行:

在我application.html.erb

<head> 
    <title><%= yield(:title) || "Untitled" %></title> 
    <%= stylesheet_link_tag "reset", "application", "facebox" %> 
    <%= javascript_include_tag :defaults, "facebox" %> 
    <%= csrf_meta_tag %> 
    <%= yield(:head) %> 
</head> 

,並在我的application_controller

class ApplicationController < ActionController::Base 
    include FaceboxRender 
end 

當我試圖在facebox加載的東西,只有裝載機,會出現什麼我有...

例如,在我家/ index.html.erb

<%= facebox_link_to "test", :url => "/images/rails.png" %> 

我會很高興知道我錯了,在DOC:

* facebox_link_to helper, it’s will launch loading facebox first, send ajax request second) 
* link_to :remote => true, form_for :remote => true …etc Ajax helper (for Rails 3) 

所以我覺得我卡發送Ajax請求..

看下面的文章後:How to make facebox popup remain open and the content inside the facebox changes after the submit看來,我有同樣的問題:我可以看到螢火蟲YHE控制檯

我的js文件不過是正確加載「阿賈克斯沒有定義」:(作爲源代碼顯示)

<link href="/stylesheets/reset.css" media="screen" rel="stylesheet" type="text/css"> 
<link href="/stylesheets/application.css" media="screen" rel="stylesheet" type="text/css"> 
<link href="/stylesheets/facebox.css" media="screen" rel="stylesheet" type="text/css"> 
<script src="/javascripts/jquery.min.js" type="text/javascript"></script> 
<script src="/javascripts/rails.js" type="text/javascript"></script> 
<script src="/javascripts/facebox.js" type="text/javascript"></script> 
<script src="/javascripts/application.js" type="text/javascript"></script> 

謝謝任何幫助!

回答

1

我所做的是先安裝facebox_render,然後安裝jRails。如果您正在重新安裝,您可能需要添加--force。

確保你有最新的jQuery。首先包含jQuery,然後是facebox.js 另外,我始終確保facebox.css先於其他樣式鏈接,它可能會覆蓋一些樣式。並驗證您是否通過視圖源使用FF,js和css鏈接正在工作。

此外,驗證這一行:

<%= facebox_link_to "Sign Up&nbsp;", :url => new_account_path, :method => :get %> 

我加了:方法=>:得到確定它創建了:

<a onclick="jQuery.facebox(function(){ jQuery.ajax({data:'authenticity_token=' + encodeURIComponent('Jbge/CYS4eXQ1d21E/S7tEcTm3dGdStdCtX9MwDx98o='), dataType:'script', type:'get', url:'/account/new'}) }); return false;" href="#">Sign Up&nbsp;</a>