Created
January 27, 2011 17:47
-
-
Save nojimage/798876 to your computer and use it in GitHub Desktop.
CakePHP Js::bufferメソッドを使う前提であれば、Js::setで値をJSへ渡すことが可能
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// in layout/default.ctp | |
?> | |
<!-- // .. snip --> | |
<?php echo $this->Js->writeBuffer(); ?> | |
</body></html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// some_view.ctp | |
// set to app.webroot | |
$this->Js->set('webroot', $this->Html->url('/')); | |
// set to app.here | |
$this->Js->set('here', $this->Html->url()); | |
// call | |
$this->Js->buffer(" | |
console.log(app.webroot); | |
console.log(app.here); | |
"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment