I am mixing a rails form_for helper with datatables that uses it's own HTML coded button, outside of form_for, to select and deselect records. However, if I click 'Select All' button atop the datatable, the page is automatically refreshed and any selection in the table will be lost:
<%= f.label :call_order %>
<%= f.check_box :call_order %>
**Datatables implementation**
<button id="selectAllRestaurantsForCampaign">Select All</button>
<button id="deSelectAllRestaurantsForCampaign">Deselect All</button>
<table id="restaurantsForCampaign" class="display" cellspacing="0" width="100%">
<... Table Code ...>
</table>
<hr>
<strong>Campaign Active</strong>
**Final attribute in form_for**
<%= f.check_box :is_active %>
<br>
<%= f.submit "Save changes", class: "btn btn-large btn-primary" %>
I want to prevent the page from refreshing until the person clicks the form_for submit button at the bottom of the page:
<%= f.submit "Save changes", class: "btn btn-large btn-primary" %>
The present CoffeeScript for the DeSelect and Select All buttons is:
# Conditional 'Select All' (works)
$("#selectAllRestaurantsForCampaign").click ->
table.$('tr', {"filter":"applied"}).addClass "selected"
# Deselecting all (works)
$("#deSelectAllRestaurantsForCampaign").click ->
table.$("tr").removeClass "selected"
How can I prevent the page from refreshing until submit is clicked?