0

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

1
  • Please share your code. Commented Jan 11, 2019 at 6:54

2 Answers 2

1

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']);

Sign up to request clarification or add additional context in comments.

Comments

0

Did You use script blocks, described here: https://book.cakephp.org/3.0/en/views/helpers/html.html#creating-inline-javascript-blocks?

1 Comment

no, i have used $this->Html->script(); with 'block' => true i correctly see the .js files but at the top of that list when i do echo $this->fetch('script')

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.