Hi I want to update/create a datatable from results of a function. I have the following code and I now need to output the results into a datatable. At the top of the page I have :
<script type="text/javascript">
$('#example').dataTable( {
paging: false,
searching: false
} );
</script>
and lower in the page I have:
myCtx.executeQueryAsync(function () {
if (queryItemCollections.length == 0) {
console.log("collection empty");
}
queryItemCollections.forEach(function (item) {
// do work with individual list items here
console.log(item.getItemAtIndex(0).get_item("Title"));
$('#example').dataTable().fnAddData( [ 'a','b'] );
});
}, genericFailHandler);
When I add $('#example').dataTable().fnAddData( [ 'a','b'] ); in the function the table does not update however when I add code outside the function it updates. Oddly, when I call up developer tools it renders. What the best way to fix this?
UPDATE: I commented console.log and now it works.. any ideas why this could be causing the issue?