My modal does not appear and there is only a black overlay
I am using
Rails version 6.0.1
Ruby version ruby 2.6.5p114 (2019-10-01 revision 67812) [x86_64-darwin18]
RubyGems version 3.0.6
Rack version 2.0.7
JavaScript Runtime Node.js (V8)
My code is largely similar to this: https://dzone.com/articles/rails-creating-modals
index.html.erb
<%= link_to 'Add user', new_item_path, {:remote => true, 'data-toggle' => "modal", 'data-target' => '#modal-window', class: 'btn btn-primary btn-lg'} %>
<div id="modal-window" class="modal fade hide" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content"></div>
</div>
</div>
_new.html.erb
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal">x</button>
<h4 class="modal-title" id="myModalLabel">Modal title</h4>
</div>
<div class="modal-body">
<%= simple_form_for @item do |f| %>
<%= f.input :title, label: "Todo", required: true, id: "font-colour" %>
<%= f.input :description %>
<%= f.input :category %>
<%= f.input :expiryDate, label: "Expiry Date", as: :date %>
<%= f.button :submit, 'submit' %>
<% end %>
</div>
<div class="modal-footer">
<button class="btn btn-primary">Save</button>
</div>
new.js.erb
$("#modal-window").find(".modal-content").html("<%= j (render 'new') %>");
$("#modal-window").modal("show");
in the controller:
def new
@item = Item.new
respond_to do |format|
format.html
format.js
end
end
I tried removing hide from the class="modal fade hide" and also changing .modal("show") to .show()
I have looked at other similar posts:
Bootstrap modal in ruby on rails not working(not show up)