Properties enclosed by quotes: how to fix this?
Properties enclosed by quotes: how to fix this?
I'm using a framework to configure the properties for Datatables. I'm using PHP and Twig. I'm building an array, containing all data (such as aaData and aoColumnDefs) and configuration (sorting, columns, etc.). The problem I'm facing is that json_encode($config) returns the JSON representation of a value, enclosed by quotes.
DataTables expects a non-quotes value, but this is what my script returns:
[code]
$('#example').dataTable({"aoColumnDefs":[{"sType":"numeric","sWidth":"100px","aTargets":[4,5]});
[/code]
My problem: 'aoColumnDefs' has to be enclosed by quotes, but 'sType' of 'sWidth' may not be enclosed by quotes.
How can I fix this?
DataTables expects a non-quotes value, but this is what my script returns:
[code]
$('#example').dataTable({"aoColumnDefs":[{"sType":"numeric","sWidth":"100px","aTargets":[4,5]});
[/code]
My problem: 'aoColumnDefs' has to be enclosed by quotes, but 'sType' of 'sWidth' may not be enclosed by quotes.
How can I fix this?
This discussion has been closed.
Replies
I removed
[code] "fnStateSave": function (oSettings, oData) {
localStorage.setItem( 'DataTables_'+window.location.pathname, JSON.stringify(oData) );
},
"fnStateLoad": function (oSettings) {
return JSON.parse( localStorage.getItem('DataTables_'+window.location.pathname) );
},
[/code] and now it works! I don't know why this was the problem?
Thanks,
Allan