2

I simply wish to call a function called fnGetNodes() to get an array of all nodes. (source of data-tables functions to calls: http://datatables.net/api)

I have set up as:

# DataTable
  table = $("#restaurantLocations").DataTable()

# Selecting all
  $("#selectAllLocations").click ->
    rows = table.fnGetNodes()

Yet as I refresh and click the button Select All I receive the following error on the line table.fnGetNodes():

enter image description here

It should be very easy, but how can I call functions on datatables in CoffeeScript?

8
  • What is table after you refresh? Is table what you expect it to be inside the callback? Is table in scope when you define that callback? Are you saying $x.DataTable() or $x.dataTable()? Commented Nov 1, 2014 at 18:24
  • I'm using .DataTable(), add seen in the code Commented Nov 1, 2014 at 19:25
  • Got it to work with replacing table.fnGetNodes() with $("#restaurantLocations").dataTable().fnGetNodes() Commented Nov 1, 2014 at 19:33
  • So it was just a typo in table = $("#restaurantLocations").DataTable() that should have been table = $("#restaurantLocations").dataTable() then? Commented Nov 1, 2014 at 19:39
  • No, some functions need .dataTable() and others .DataTable, so I just call an instance of $("#restaurantLocations").dataTable() on those other functions Commented Nov 1, 2014 at 19:52

0

Your Answer

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

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.