我找到了一个可行的解决方案,希望没有不可预见的问题。
$(document).ready ->
initLeagueIndexDataTable()
$(document).on 'pjax:end', ->
initLeagueIndexDataTable()
initLeagueIndexDataTable : ->
if ($('#league_index').length > 0 && !$('#league_index_wrapper').length > 0)
$('#league_index').dataTable({
'sPaginationType': 'full_numbers',
'bJQueryUI': true,
'bProcessing': true,
'bServerSide': true,
'sAjaxSource': $('#league_index').data('source'),
'aoColumnDefs': [
{ "bSortable": false, "aTargets": [ 1 ] },
{ "bSortable": false, "aTargets": [ 2 ] },
{ "bSortable": false, "aTargets": [ 3 ] },
{ "bSortable": false, "aTargets": [ 4 ] },
{ "bSortable": false, "aTargets": [ 5 ] }
],
'bFilter': false,
'iDisplayLength': 25,
'bDestroy': true
})