Optimal way to refresh an editor table

Optimal way to refresh an editor table

rdmrdm Posts: 194Questions: 55Answers: 4
edited October 2017 in Editor

I have a "mass update" button on my page that applies a mass update to the database, and then refreshes the editor table.

Looking around the various examples, I pieced together this technique. My question is whether there is a better technique than to new up a table. The following code does work.

function refreshTable () {          
    var refreshTable = $('#example').DataTable();
    refreshTable.draw();
}

Without success, I have tried $('#example').draw(); and received in the console log Uncaught TypeError: $(...).draw is not a function

I have also tried $('#example').ajax.reload(); and received the error Uncaught TypeError: Cannot read property 'reload' of undefined

I just wanted to make sure I wasn't missing out on an existing technique that doesn't require newing up a table.

This question has an accepted answers - jump to answer

Answers

  • kthorngrenkthorngren Posts: 21,336Questions: 26Answers: 4,951
    Answer ✓

    You need to add .DataTable() to get the APIs. For example:

    $('#example').DataTable().ajax.reload();
    

    I'm thinking ajax.reload() is what you want to use to refresh the data from the DB.

    Kevin

This discussion has been closed.