map_table.rows is not a function

map_table.rows is not a function

ak47ak47 Posts: 16Questions: 5Answers: 2
$("body").on 'click', "#map_button", ->
    console.log $('[id$=listings_map_table]')
    map_table = $('[id$=listings_map_table]').DataTable
    console.log map_table
    map_table.rows().every ->

The error is: Uncaught TypeError: map_table.rows is not a function

This is a page where the DataTable is created and drawn after the page is rendered based on user action. The table looks fine, and in my console I can see the object if I just spit the object to the console.

If I try to do an entire initialization, it tells me it can't reinitialize the table. But if I just do like the above, I get the ".rows is not a function" error.

What am I missing here?

Answers

  • allanallan Posts: 61,635Questions: 1Answers: 10,092 Site admin

    The syntax looks a little unusual - I'm guessing it is transpiled into Javascript, but I don't recognise it. What is it?

    $('[id$=listings_map_table]').DataTable
    

    should be:

    $('[id$=listings_map_table]').DataTable()
    

    is my guess, but it looks like whatever language it is, is trying to fill in parenthesis in places, and it isn't doing so there?

    Allan

  • ak47ak47 Posts: 16Questions: 5Answers: 2

    This is CoffeeScript. You're the man, that worked immediately!

Sign In or Register to comment.