I try to update the Datatables when you click the button. My JQuery code in "spr_well_types.js.coffee":
jQuery ->
sprWellTable = $('#spr_well_types').dataTable
sPaginationType: "full_numbers"
bJQueryUI: true
bProcessing: true
bServerSide: true
sAjaxSource: $('#spr_well_types').data('source')
$(document).ready ->
$("#Refresh").on "click", (event) ->
sprWellTable.fnDraw()
My page "index.html.erb":
<button id="Refresh" type="button">Refresh</button>
<table id="spr_well_types" class="display" data-source="<%= spr_well_types_url(format: "json")%>">
<thead>
<tr>
<th>Name</th>
<th>Short Name</th>
<th>Lock version</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
Code I click on the Refresh button in the browser error "ReferenceError: sprWellTable is not defined". I saw the theme, but the code:
$("#Refresh").click ->
sprWellTable.fnDraw()
Not tied to the Refresh button.