I am using Rails 4 and jQuery-File-Upload and have some problems with form validation and jQuery activation. After I submit a form if there are some errors inside form I render form again inside my respond_to js.erb file like this:
<% if @cat.new_record? %>
$('#new_cat').html('<%= j render('form') %>');
<% else %>
...
<% end %>
This displays all validation errors but at the same time disables jQuery-File-Upload which doesn't initialize again. Now when I want to submit a new form it doesn't work correctly and it just displays code after submit because no jQuery functions are present. What can I do to initialize jQuery again after I render the form again.
I tried to place this inside my coffeescript but no help:
$(document).on "ready page:load", initMyFunction
It doesn't record rendering of the form as the page load. Any ideas?