ypnos-web / cakephp-datatables

CakePHP3 Plugin for DataTables plug-in for jQuery
MIT License
27 stars 24 forks source link

Cake v4 issues and workaround. #86

Open alanapplyby opened 2 years ago

alanapplyby commented 2 years ago

I have noted a few users have reported an issue when using this plugin with Cake v4. I have done a little investigation my side side and found the following.

The following line seems to cause an issue:

$js .= $this->Html->scriptBlock($code, ['block' => true]);

Specifically the block true param. Changing this to false fixes the issue, or else leaving it as true then in the template:

<?= $this->DataTables->table('requests', $options, ['class' => 'table table-striped']); ?>
<?= $this->fetch('script'); ?>

It is not clear to me why this works though and if it is an acceptable approach - hope this helps.