Sometimes, it's a requirement to place submit button outside the form tag. Following is the example code for doing so.
You can create a button outside the form, and use jquery to submit the form when the button is clicked:
HTML:
<button id="myBtn" class="btn btn-primary">Accept Checked</button>
...
<%= form_tag select_cosmics_path, method: :put, id: 'myForm' do %>
...
<% end %>
JQUERY:
$(document).ready(function() {
$('#myBtn').on('click', function() {
$('#myForm').submit();
});
});
That's it...
You can create a button outside the form, and use jquery to submit the form when the button is clicked:
HTML:
<button id="myBtn" class="btn btn-primary">Accept Checked</button>
...
<%= form_tag select_cosmics_path, method: :put, id: 'myForm' do %>
...
<% end %>
JQUERY:
$(document).ready(function() {
$('#myBtn').on('click', function() {
$('#myForm').submit();
});
});
That's it...