HTML5 data attribute for sAjaxSource

HTML5 data attribute for sAjaxSource

bartbart Posts: 2Questions: 2Answers: 0
edited April 2014 in General
Hi everybody,

I like to pass a data attribute as ajaxSource, because I'm using dynamic tables.
I tried something like

$('.datatable table').dataTable({
"sAjaxSource": "/api/" + $(this).data('source')
});

but I get the string unknown for $(this).data('source').
When I add

"fnInitComplete": function () {
console.log($(this).data('source'));
}

the attribute is shown correctly.

Do you have any idea how to solve this?


Thanks and regards,
bart

Replies

  • bartbart Posts: 2Questions: 2Answers: 0
    Found a solution with an each() loop. Not perfect but working.
  • allanallan Posts: 63,689Questions: 1Answers: 10,500 Site admin
    In 1.10 you can use the `DT_RowData` object property to send back parameters that will be added to the`tr` as data: http://next.datatables.net/manual/server-side#Returned-data . The documentation there is specifically for server-side processing but `DT_RowData` and friends will also work okay for client-side processing with Ajax loaded data.

    Allan
This discussion has been closed.