where is the best place to put the jquery and javascript scripts in zend framework?
shall i put every script in js file and append in the controller like :
$this->view->headScript()->appendScript
or to leave in the phtml page as is ?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
I’d say it depends on your scripts, if your script is linked to your controller, you could include it in the
_init()method of your controller.I usually prefer to include my .js scripts inside my view (when they concern only one unique view) using
$this->jQuery()->addOnload()for jQuery and:for js scripts.
As you can see in this second example, a real advantage to use captureStart() is that you can use PHP to generate contents in your Javascript. It can be pretty useful for translating a word for example.
Finally,
_initView()method in your bootstrap is a good place to put web-site relative .js.