Get datatable 1.10 as jquery object
Get datatable 1.10 as jquery object
Muhahe
Posts: 25Questions: 8Answers: 2
Hi, is possible, to get jquery object from datatable variable in 1.10?
If i initialize table like this
var table = '<table id="projects_table">'+
'<thead>'+
'<tr>'+
'<th></th>'+
'<th>Project ID</th>'+
'<th>Customer</th>'+
'<th>Platform</th>'+
'</tr>'+
'</thead>'+
'<tr><th>0</th><th>1</th><th>2</th><th>3</th></tr>'+
'</table>';
var dTable = $(table).dataTable();
i get jquery object to variable dTable
but when i use (capital D)
var table = '<table id="projects_table">'+
'<thead>'+
'<tr>'+
'<th></th>'+
'<th>Project ID</th>'+
'<th>Customer</th>'+
'<th>Platform</th>'+
'</tr>'+
'</thead>'+
'<tr><th>0</th><th>1</th><th>2</th><th>3</th></tr>'+
'</table>';
var dTable = $(table).DataTable();
I get datatable api. Its way to get jquery object from capital D initialization? Because if i understand well, initialization without capital D is for old datatables. Or am i wrong?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
See
to$()
Incidentally your table is just a HTML string and isn't in the DOM when you're creating a datatable api. I suspect this may give you issues.
Not the old DataTables, but rather
$().dataTable()
and$().DataTable()
return different things and both are fully supported. If you want the jQuery object use$().dataTable()
.Allan
Thanks for it Allan, my mistake i didnt know it.
vogomatix: i think it is possible to create datatable on HTML string which ones representig element (before inserting to DOM). In example 1 if i insert dTable into DOM, datatable appears here