views:

108

answers:

1

I'm setting a local path for jQuery in my layout. Then adding another js file using appendFile, but it's not adding the file I'm appending.

in layout:

$jquery=$this->jQuery();
$jquery->enable(); // enable jQuery Core Library
$jquery->setLocalPath($this->baseUrl().'/js/jquery-1.3.2.min.js');
echo $jquery;
echo $this->headScript();

In my view:

$this->headScript()->appendFile($this->baseUrl().'/js/jquery.corner.js');

thanks for any help

A: 

You need to put the following line in your action, instead of your view:

$this->view->headScript()->appendFile($this->view->baseUrl().'/js/jquery.corner.js');

The line echo $this->headScript(); is being executed before any of your view code is, so it won't take your appendFile() statement into account. If you put it in your action, the action code is called before the layout and view are rendered, so it will take it into account.

Mark
That's not working either. I think it's an issue with how jQuery is added. If I don't use "$jquery->setLocalPath" , then zend will try to include it from Google code. But I'm using a local copy of jQuery.
EricP
Alex Osborn