I'm using CakePHP 2.x
I have a couple elements that require javascript files, so inside the element ctp file (whatever.ctp) I do something like this: $this->Html->script('whatever.js', array('inline'=>false)); This normally works great...
But I noticed that when I try to use this exact same element directly on a layout (not a view) it doesn't work:
//inside default.ctp layout echo $this->element('whatever');
The element shows up normally, but the scripts do not get added to the script block. If I move that same element into a view, the scripts do get added. Or if I take the scripts out of the element and just add $this->Html->script('whatever.js', array('inline'=>false)); to the default. That also works.
So why can't elements add to the script block outside of a view?
In case it's not clear...
//this works
layout -> view -> element -> $this->Html->script()
//this works
layout -> $this->Html->script()
//this DOESN'T work
layout -> element -> $this->Html->script()
echowhen using inline=>true?'inline'=>false. Whether I set it to true or false, no script tag appears (when$this->Html->script()is inside the element that's used in the layout).