Reputation: 29795
I am using the jquery data table like this:
$.fn.tkDataTable = function(){
"order": [[ 7, 'asc' ]]
if (! this.length) return;
if (typeof $.fn.dataTable != 'undefined') {
this.dataTable();
}
};
I get the error:
Uncaught SyntaxError: Unexpected token :
I get this on the line with "order". How can I correctly set this attribute without the syntax error?
Upvotes: 0
Views: 44
Reputation: 171690
You rarely call datatable without an options object
I suspect what you want is something like
$.fn.tkDataTable = function(){
var opts = {
"order": [[ 7, 'asc' ]],
//... other initialization properties
};
if (! this.length) return;
if (typeof $.fn.dataTable != 'undefined') {
// pass options to plugin
this.dataTable(opts);
}
}
Upvotes: 1