ShowHide

srboisvert edited this page Sep 12, 2010 · 5 revisions

Sample: you want to show a list of emails, and when you click the ‘show details’ link, a box with the user’s details appears:

<% for user in @users %>

  <%=h user.login %> <%= show_box_for user, :link_name=> 'show user details' %><!-- this is the link to open the detail box-->

  <% detail_box_for user do %> <!-- this defines the initially hidden box -->
    <%=h user.name %>
    <%=h user.surname %>
    <%= link_to 'Show', user %>
    <%= link_to 'Edit', edit_user_path(user) %>
    <%= link_to 'Destroy', user, :confirm => 'Are you sure?', :method => :delete %>
    <%= hide_box_for user %> <!-- this is the link to close the detail box -->
  <% end %>

<% end %>

You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.
Press h to open a hovercard with more details.