javascript - Application Wide Modal Issue rails 5 Bootstrap 3 -


i have setup modals new , edit actions in users controller. keep display consistency user show page appear in modal well.

right users access show page via

<li><%= link_to "view profile", current_user %></li> 

link in nav-bar.

i set link display desired modal show action in user controller.

im stuck, i've tried google how don't think asking right questions. if can direct me resource or give me general outline of how achieve appreciated!

i realize question bit vague i'm not sure how else proceed.

you can use rails js if want load profile when clicked.

1. set remote: true on link tag.

<li><%= link_to "view profile", current_user, remote: true %></li> 

2. create partial containing modal can render via rails js.

app/views/users/_show.html.erb

<%= content_tag :div, class: "modal fade", id: dom_id(@user, :modal) %>   <div class="modal-dialog">     <div class="modal-content">       lorem ipsum...     </div>   </div> <% end %> 

3. append partial containing modal , toggle using rails js. rails corresponding .js.erb view when remote: true set.

app/views/users/show.js.erb

$('body').append('<%= j render "users/show" %>');  // append modal $('#<%= dom_id @user, :modal %>').modal('toggle'); // toggle modal 

Comments

Popular posts from this blog

amazon web services - S3 Pre-signed POST validate file type? -

c# - Check Keyboard Input Winforms -