I use the jquery plug-in
dataTables to format tables to display a range of products. dataTables offers a lot of options to format a table and I’m having a problem with one of them. Here is the code of the call I have in the template
<script type="text/javascript">
$(document).ready(function() {
$("#sqlQueryResultTable").dataTable({
"aoData": [
null,
null,
null,
null,
null,
null,
null,
null,
{"bSortable": false, "bSearchable": false},
{"bSortable": false, "bSearchable": false}
],
"sPaginationType": "full_numbers",
"oLanguage": {"sUrl": "[(base_url)]assets/templates/kniel_mf54/js/dataTables-1.5/media/language/en_UK.txt"},
"aaSorting": [[1, "desc"]]
} );
} );
</script>
This is pretty straight forward and works in a static page. The last parameter
aaSorting however causes the trouble if MODx caomes into play. The problem is, the parameters for aaSorting are given as an array surrounded by a pair of brackets for the array and another pair of brackets for each pair of parameters (see the documentation
here). Since MODx uses double brackets for the inclusion of snippets, this does not work. The codes gets parsed and the content between the parameters gets thrown away by MODx. When the page loads, I get a JavaScript syntax error.
Is there a way to escape the double brackets so I can hand over the parameters and not let MODx interpret this as a snippet?