I have a form with remote option set. I need to trigger the submit programmatically.
In Rails 4 I use $('form').trigger('submit.rails') and it works as expected.
In Rails 5 (5.1.2 and 5.0.4) triggering that event causes a standard submit (formdata, not AJAX).
For Rails staff 'submit.rails' is not part of Rails project, see here
Any idea?
UPDATE:
Form code:
<%= form_with(model: post, remote: true) do |form| %>
<% if post.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(post.errors.count, "error") %> prohibited this post from being saved:</h2>
<ul>
<% post.errors.full_messages.each do |message| %>
<li><%= message %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="actions">
<%= form.submit %>
</div>
<% end %>
submit.rails. where does it come from?jquery-rails. Can you ensure that this is included in your project?$('form').submit()