Facebox问题

时间:2011-02-21 17:06:45

标签: ruby-on-rails facebox

对不起,有人可以给我发一个完整的教程或发布一个关于Facebox的例子,因为它的文档很差。

我的问题是ajax请求没问题,但没有显示任何包含内容的弹出窗口。

也许我忘记了步骤。

我的代码

应用程序控制器

class ApplicationController < ActionController::Base
  include AuthenticatedSystem
  include RoleRequirementSystem
  include FaceboxRender

...

end

应用程序布局

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
            "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
    <head>
      <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>

      <title><%= configatron.site_name %></title>

      <%= stylesheet_link_tag "facebox" %>
      <%= stylesheet_link_merged :base %>
      <%= javascript_include_merged :base %>
      <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
      <%= stylesheet_link_tag 'mobile' if mobile_device? %>
      <%= javascript_include_tag('jquery.simplemodal') %>
      <%= javascript_include_tag("jquery.form") %>
      <%= javascript_include_tag "facebox" %>
      <script type="text/javascript">
          $j = jQuery.noConflict();
          jQuery(document).ready(function($) {
            $('a[rel*=facebox]').facebox()
          })

      </script>
    </head>
...
...

索引视图

<% content_for :header do %>Lista de Pack<% end %>

<%= facebox_link_to "Ver packs", :url => {:controller => "packs", :action => "prueba"}, :method => :get -%>

prueba view

<div id="pack-list">
 <h1>HOLA</h1>
</div>

打包控制器

  def index
  end

  def prueba
    @packs = Pack.paginate :page => params[:page], :per_page => 5

    respond_to do |format|
      format.html
      format.js { render_to_facebox }
    end
  end

1 个答案:

答案 0 :(得分:1)

正如它在这里所说:http://chriswanstrath.com/facebox/

<a href="remote.html" rel="facebox">text</a>

<script src="jquery.js" type="text/javascript"></script>
<link href="/facebox/facebox.css" media="screen" rel="stylesheet" type="text/css"/>
<script src="/facebox/facebox.js" type="text/javascript"></script>
<script>
  jQuery(document).ready(function($) {
    $('a[rel*=facebox]').facebox() 
  })
</script>