Search code examples
ruby-on-rails-3.1facebox

Not able to render partial using facebox with rails


I am using facebox to get some information in a popup window.

I have got facebox.js and facebox.css file in my assets folder. I have included this code in my application.js file

jQuery(document).ready(function($) {
  $('a[rel*=facebox]').facebox()
});

I have link_to which looks like this <%=link_to "Create",new_activities_path, :rel => "facebox" %>

When I click on the create link I get a popup which is empty and does not render the form which is in the partial.

I am able to render this partial without facebox. I have been looking all over the net but it seems the documentation of facebox is not that good.

Can anyone guide me?

Thanks,


Solution

  • Was able to do it by tweaking the code little bit :-

    now my link_to looks like this <%=link_to "Create",new_activity_path, :remote => true %>

    I also have a new action in the controller and a corresponding new.js.erb file which has got the below mentioned code:-

    $.facebox('<%= escape_javascript(render :partial => 'new') %>')
    

    the code in the application.js remains the same. I am able to render the partial in _new.html.erb in a nice popup.

    Hope it will be useful to others as the documentation of facebox is very poor.

    Thanks,