Action Link to reload entire scaffold but not entire page

52 views
Skip to first unread message

Jim

unread,
Jun 4, 2012, 6:41:08 PM6/4/12
to actives...@googlegroups.com
I have an embedded scaffold.  I'd like to put an action link at the top (:type => :collection) that simply changes a parameter and reloads the scaffold.  Currently, the action link does reload the rows, but not the header. The problem is that I need to update the header to also change the action link and list label.

I have added the action link with the following options:

 :type => :collection, :page => false, :position => false, :action => 'index', parameters = {:show_deleted => 0}

I tried also specifying :inline => true, but that didn't have any effect.

Any ideas?

Jim

Sergio Cambra

unread,
Jun 5, 2012, 7:17:09 AM6/5/12
to actives...@googlegroups.com
Your link is ok, inline true and page false are defaults, but ActiveScaffold
doesn't reload header by JS. You can use :page => true, or you can override
_refresh_list.js.erb, for example:
<%= render :super %>
jQuery('#<%= active_scaffold_id -%>').html('<%=j render :partial =>
'list_header' %>');

Jim

unread,
Jun 5, 2012, 1:07:01 PM6/5/12
to actives...@googlegroups.com
I probably should have mentioned that I'm using Rails 3.0.x, so I have to use ActiveScaffold 3.0.26 (right?).  That version doesn't have _refresh_list.js.erb.  

I did just now figure out a workaround.  Since I'm embedding the scaffold with an ajax link, I had to create a "list_names" action to call, which simply renders the scaffold with:

<%= render :active_scaffold => 'composite_names' %>

So, I just made a "toggle_deleted" action, which renders my list_names action to a string, and then replaces the whole active scaffold:

  def toggle_deleted
    as_table = render_to_string(:action => 'list_names', :layout => false).html_safe
    render :update do |page|
      page.replace active_scaffold_id, as_table
    end
  end

The action link is using {:type => :collection, :position => false, :inline => false}.  Inline has to be false or the render :update fails, and any other kind of rendering embeds the text into the inline adapter.

Jim

Reply all
Reply to author
Forward
0 new messages