Rails/facebox_render - Ajax 未定义(facebox 始终加载...)

发布于 2024-09-28 12:03:21 字数 2062 浏览 3 评论 0原文

我尝试使用facebox_render和rails 3进行简单的测试。

这是我的步骤:

1.)安装了Jquery 1.4.2(Jrails)

2.)安装了插件 Rails Plugin install 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 中加载某些内容时,我只有加载器,什么也没有出现...

例如,在我的 home/index.html.erb 中

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

,我很高兴知道我错在哪里,在文档中:

* 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 请求..

在查看了以下帖子:如何为了使facebox弹出窗口保持打开状态,并且在提交后facebox内的内容发生变化似乎我也遇到了同样的问题:我可以在firebug控制台中看到“Ajax未定义”

但是我的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>

感谢您的帮助!

I tried to make a simple test with facebox_render and rails 3.

Here are my steps:

1.) Installed Jquery 1.4.2 (Jrails)

2.) Installed the plugin
rails plugin install git://github.com/ihower/facebox_render.git

3.) and added the following lines:

in my 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>

and in my application_controller

class ApplicationController < ActionController::Base
  include FaceboxRender
end

When I tried to load something in the facebox, I have only the loader, nothing appears...

for example, in my home/index.html.erb

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

I would be pleased to know where I am wrong, In the 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)

So I think I'm stuck to send ajax request..

After looking the following post: How to make facebox popup remain open and the content inside the facebox changes after the submit it seems that I have the same problem: I can see "Ajax is not defined" in yhe firebug console

My js files is however correctly loaded: (as the source code shows)

<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>

Thanks for any help!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

浮生面具三千个 2024-10-05 12:03:21

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

确保您拥有最新的 jQuery。首先包含 jQuery,然后包含facebox.js
另外,我总是确保 Facebox.css 在其他样式之前首先链接,它可能会覆盖您的某些样式。并通过查看源代码验证您是否使用 FF,js 和 css 链接是否正常工作。

另外,验证这一行:

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

我添加了 :method => :确保它创建:

<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 </a>

what i did is install facebox_render first, then jRails. You might want to add --force if you are reinstalling.

Make sure that you have the latest jQuery. Include jQuery first then the facebox.js
Also, I always make sure that the facebox.css is linked first before the other styles, it might overwrite some of your styles. And verify if you're using FF via view source the js and css links are working.

In addition, verify this line:

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

I added the :method => :get to make sure it creates:

<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 </a>
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文