0

I want to send a script from view to the bottom of the layout in order to get the script executed in last.

At the moment, I'm using this in my layout :

echo $this->fetch('scriptBottom');

And

$this->Html->script('myjs', array('block' => 'scriptBottom'));

in my view, at the very bottom of the body.

But in my view

$this->Html->script('alert(\'lol\''), array('block' => 'scriptBottom'));

Doesn't work.

As I need to generate js code from php, how can I do?

PS I already checked this and it didn't help : http://api.cakephp.org/2.4/class-HtmlHelper.html#_script

1 Answer 1

1

Shouldn't you use

$this->Html->scriptBlock('alert("lol")', array('block' => 'scriptBottom'));

?

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

Comments

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.