I'm trying to dynamically ad rows to a blank datatable. However, it instead of the text displaying on the screen it's coming back as [object Object] in each column. I've tried multiple things, but can't figure out what's wrong with it.
my html is just a basic table
and my js looks like this
var commentTable = $('.commentTable').DataTable({
columns: [
{
class: "commentDate",
data: null
},
{
class: "commentUser",
data: null
},
{
class: "commentComment",
data: null
}
],
bSort: false
});
$('.addComment').on('click', function () {
var newCom = $('.newCommentArea').find('input').val();
var dateInput = moment().format("dd MM, YYYY");
var rowNode = commentTable
.row.add({
"date": dateInput,
"name": 'name',
"comment": newCom
})
.draw(false)
.node();
commentTable.page('last').draw(false);
$(rowNode)
.css('background-color', 'lightyellow')
.animate({
color: 'black'
});
$('.newCommentArea').find('input').val('');
});
class? It must beclassName.