1

I'm using datatables on a Rails site and intend to make use of its' row reordering plugin. The documentation on the datatables site says implementation is easy - all I need to do is;

$(document).ready(function(){
 $('#example').dataTable()
      .rowReordering();
});

But for the life of me I can't figure out how to accomplish this with CoffeeScript, or if this is even necessary. My current ds.js.coffee file looks like this;

jQuery ->

  $('#thetable').dataTable
    bDestroy: true,
    sPaginationType: "full_numbers",
    bAutoWidth: false,
    aLengthMenu: [[25,50,100,-1],[25,50,100,"All"]],
    iDisplayLength: 50,
    aoColumns: [{ "bSortable": false }, null,null,null,null,null,null,null,null],
    aaSorting: [[ 1, 'asc' ]],
    bStateSave: true;

  $(document).ready ->
    $('#thetable').dataTable
      .rowReordering();

But after managing this there's no drag and drop on the table.

1 Answer 1

1

This is not a function call:

$('#thetable').dataTable # <----------------
  .rowReordering();

The function-calling parentheses are not optional when you're calling a function without arguments (and various other places), you need to say:

$('#thetable').dataTable().rowReordering()

or

$('#thetable').dataTable()
  .rowReordering();
2
  • Yes, I should've spotted that. Thanks. However this is not the only issue preventing the re-ordering. I have it now and I believe that jqueryui was not being included. Additionally there was some more configuration of the datatable required - it's not as simple as the documentation makes out.
    – mvanio
    Sep 13, 2013 at 12:32
  • @ObregonCornsnook: The documentation tends to present a simplified version of reality :) Sep 13, 2013 at 17:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.