[TYPO3-mvc] Best Practice? Passing Values to JavaScript within a Template
Tim Schoch | GSTALTIG
tim.schoch at gstaltig.ch
Tue Apr 26 09:20:19 CEST 2011
Hello
I'd like to pass some values from the controller to the javascript files within the Resources Folder.
As an Example, lets prompt a User with his name (everybody loves to read his name!):
$this->view->assign( 'name', $feUser->getName() );
alert( 'Hello {name}!' );
alert( 'Nice to have you, {name}, here!' );
alert( 'Sir, {name}, we love you!' );
Unfortunately we live in a more complex world with javascript code scattered over a dozen of files with ajax requests and multiple
values that should be handed to the different parts of the application, how would you pass the values?
My guess was to create a «insertJavaScriptValues» Partial and pass the values to it where they get written to the html code where
they would be globally available. Not very nice. And how about Caching? Has anybody done something similar yet?
Thanks Tim
More information about the TYPO3-project-typo3v4mvc
mailing list