I'm using a form in my rails application, in my controller at the end I check if the content of the form is ok or not, if not I render the page again explaining on top the errors
part of controller
if @insertion.save
redirect_to @insertion
else
render 'new'
end
and in my view I've got this line to show the errors.
<% if @insertion.errors.any? %>
<div id="error_explanation">
<div class="alert alert-danger">
The form contains <%= pluralize(@insertion.errors.count, "error") %>.
</div>
<ul>
<% @insertion.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
the problem is that after the render the page will not load again my javascript file, so the view isn't as I expected
How can I force to reload js after render?
this is my coffee file due to turbolink
$(document).on "turbolinks:load", ->
insertionJS = new Insertion()
if $('.insertions.show').length > 0
console.log("insertions.show")
insertionJS.showJS() .....continue