jquery - DataTables .draw() not firing properly -


okay, have datatable i'm trying re-render when clear button clicked.

when filter table through custom, filters, works expected. however, when click 'clear' inputs cleared expected, table doesn't redrawn. rather, table still displays 'no matching records found'. there no errors being thrown in console , same code works in template.

any thoughts?

var table = $('#pages').datatable({   'ordering': true,   "columndefs": [     { "name": "title", "targets" : 0},     { "name": "path", "targets" : 1 },     { "name": "created", "targets" : 2 },     { "name": "updated", "targets" : 3 },     { "name": "creator", "targets" : 4 },     { "name": "templatename", "targets" : 5 },     { "name": "status", "targets" : 6 },     { "name": "includeonmenu", "targets" : 7 },   ],     "dom": 'tip'   }); $('.clear-filter').click(function() {   $("#filter :input").each(function() {     this.value = "";   });   table.draw(); }); 

you should able use table.destroy(); before table.draw();. it's you're "filtering" somehow before table draw, causing problem. table.destroy(); take out filtering , can draw scratch.

https://datatables.net/reference/api/destroy()


Comments