I have a Thymeleaf template with a Datatable (1.10.15). I have this datatable defined in 1 of my Thymeleaf template :
<script th:inline="javascript">
$(document).ready(function() {
$('#deviceEventTable').dataTable( {
order: [[ 0, "desc" ]],
select: true,
bLengthChange: false,
stateSave: true,
pageLength: 20,
initComplete: function() {
var api = this.api();
if (localStorage.getItem( 'DataTables_selected' )!=null && localStorage.getItem( 'DataTables_selected' ) != 'undefined') {
var selected = localStorage.getItem( 'DataTables_selected' ).split(',');
var selected = '0';
selected.forEach(function(s) {
api.row(s).select();
})
}
}
});
table.on('select.dt deselect.dt', function() {
localStorage.setItem( 'DataTables_selected', table.rows( { selected: true }).toArray() )
})
} );
</script>
But I got this error when I init the page:
Caused by: org.xml.sax.SAXParseException; lineNumber: 214; columnNumber: 64; The entity name must immediately follow the '&' in the entity reference.
Use CDATA in script
<script th:inline="javascript">
/*<![CDATA[*/
//Your code
/*]]>*/
</script>
Otherwise & in condition parsing as the start of an entity
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With