Advertisement
klashe

How to link_to collapse on another page using anchor

Aug 29th, 2019
2,479
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Rails 1.16 KB | None | 0 0
  1. Link on notifications page:
  2. <%= link_to main_app.recipe_path(notification.second_target.recipe, notification.second_target.id, anchor: "comment_#{notification.target.id}"), class: "dark-link" do %>
  3.  
  4. On the recipes page, I displayed all reviews comment
  5. <section class="comment-container">
  6.     <p class="notifications-p">
  7.       <button class="btn btn-default btn-sm mb-2" type="button" data-toggle="collapse" data-target="#collapseComments-<%= review.id %>" aria-expanded="false" aria-controls="collapseComments-<%= review.id %>">
  8.         <% unless review.comments.blank? %>
  9.           <small><i class="fa fa-comments text-muted"></i>View comments<i class="fa fa-chevron-down text-muted"></i></small>
  10.         <% else %>
  11.           <small><i class="fa fa-comment text-muted"></i>Add Comment<i class="fa fa-chevron-down text-muted"></i></small>
  12.         <% end %>
  13.       </button>
  14.     </p>
  15.     <div class="collapse" id="collapseComments-<%= review.id %>">
  16.       <div class="comments-card">
  17.         <%= render "comments/widget", commentable: review %>
  18.       </div>
  19.     </div>
  20. </section>
  21.  
  22. _comment.html.erb
  23.  
  24. <li id="comment_<%= comment.id %>" class="comment">
  25. ...
  26. </li>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement