Trying to initialize an already initialized DataTable causes function to exit improperly.

Trying to initialize an already initialized DataTable causes function to exit improperly.

ak47ak47 Posts: 16Questions: 5Answers: 2
edited May 2015 in Free community support

I just upgraded to v1.10.3 and my code is broken now. It's really simple.

When my page loads, there is a text box, and an empty table that is initialized as a DataTable by JS code.

The user enters a value in the text box and clicks a button. The button is wired to JS code that does an AJAX submission. Then my server code returns data and the table is populated.

In the button JS code, I re-iniitialized the DataTable so that I could clear out the table with fnClearTable.

But now, that fnClearTable line causes my JS function to exit. There are no errors, no console messages, nothing.

  $("#research_button").click ->
    $("#research_table").DataTable.fnClearData()
    alert("made it here")
    data = { term: $("#research_term").val() }
    hash = { type: "GET", url: "search", data: data }
    $.ajax(hash)
    false

See that alert? It never fires. Why is the table not initializing?

This question has an accepted answers - jump to answer

Answers

  • ak47ak47 Posts: 16Questions: 5Answers: 2
    Answer ✓

    The old API wasn't working for me, either for fnClearData or for adding rows. I switched to the new API calls and everything works!

This discussion has been closed.