August 18, 2009
scripts_for_layout is generated _before_ the layout is rendered. Therefore it cannot contain scripts from elements that are included in the layout as that would require bending of space time. As templates are just plain PHP, and are parsed by the PHP interpreter only.
There are alternative solutions for this in the works, but at this time rebuilding space time is a too large of a task. :)
I think the CakePHP team will find some solution for this. Before that you can use the solution_ therma_lobsterdore_ provided:
You can get around this problem by manually recreating scripts_for_layout. Remove $scripts_for_layout from your view and replace it with this...
echo join("\n\t", $this->__scripts);
I hope this helps some people experiencing the same problem :)