I have a menu item that fires ajax that returns javascript partial that is a bootstrap modal. The problem I am having is when a user clicks the menu item the first time, the modal opens as expected. The user closes the modal and tries to open it again, it doesn't open (although the ajax fires again from backend).
Consider the following code (using bootstrap 4):
Menu.html.erb:
<div class="dropdown-menu dropdown-menu-right" aria-labelledby="navbarDropdownMenuLink">
<%= link_to user_profile_path(current_user.user_profile.id), remote: true, class: "dropdown-item" do %>
<%= fa_icon "id-card", text: "Profile Settings" %>
<% end %>
</div>
...
<div id="user_profile"></div>
user_profile/show.js.erb (ajax js partial):
$("#user_profile").replaceWith("<%= j render "user_profile" %>");
user_profile/_user_profile.html.erb (bootstrap modal):
<script>
$('#user_profile_modal').modal('show');
</script>
<%= form_with model: @user_profile do |f| %>
<div class="modal fade" id="user_profile_modal" tabindex="-1" role="dialog">
<div class="modal-dialog modal-lg" role="document">
...
</div>
</div>
<% end %>
Is there a way to fire the the modal('show'); each time the modal is fired from the backend? By the way, this is just one of 3 modals that get loaded this way on the page.
Thanks again!