Reputation: 4608
i am using cakephp 3.7 and i load few .js file in my default.ctp layout. The problems comes when i try to add other .js in my view. These js files are added at the beginning of the js file list. I do echo $this->fetch('script'); to print that block.
For example, i am using jquery, i load this library in default.ctp because i use it everywhere, the problem is that view js are loaded before jquery so i cannot use $
how can i "append" to script block, inside an action's view? Thanks
Upvotes: 0
Views: 525
Reputation: 26
In your layout put (before < /head> if you wish) $this->fetch('my_head_script') , then in your view use $this->Html->script("jquery.js",['block' => 'my_head_script']);
Upvotes: 1
Reputation: 2968
Did You use script blocks, described here: https://book.cakephp.org/3.0/en/views/helpers/html.html#creating-inline-javascript-blocks?
Upvotes: 0