ZF2-376: HeadScript Prepend/Append

Issue Type: Bug Created: 2012-06-22T22:26:55.000+0000 Last Updated: 2012-07-02T15:52:04.000+0000 Status: Resolved Fix version(s): Reporter: Sammie S. Taunton (diemuzi) Assignee: Matthew Weier O'Phinney (matthew) Tags: Related issues: Attachments:


Based on my layout.phtml which I slightly edited from the SkeletonApp, I have the following:

Now I have created a new module named Login and I would like to add a new script "under" the jQueryUI file from one of my view scripts. In popup.phtml I have tested the following:

$this->headScript()->appendFile($this->basePath() . '/js/Custom/Login/dialog.js', 'text/javascript'); $this->headScript()->prependFile($this->basePath() . '/js/Custom/Login/dialog.js', 'text/javascript');

This results in the following: (Regardless of appendFile or prependFile)

It should be: (Using the appendFile)


Posted by Ryan Mauger (bittarman) on 2012-06-22T22:30:54.000+0000

How did you add the files in your layout.phtml? if you did it with append also, then that would explain this

Posted by Sammie S. Taunton (diemuzi) on 2012-06-22T22:32:53.000+0000

Application - Layout.phtml

$this->headScript()->appendFile($this->basePath() . '/js/jQuery/jquery-1.7.2.min.js', 'text/javascript') ->appendFile($this->basePath() . '/js/jQuery/jquery-ui-1.8.21.custom.min.js', 'text/javascript');

Login - Popup.phtml

$this->headScript()>appendFile($this>basePath() . '/js/Custom/Login/dialog.js', 'text/javascript');

Posted by Sammie S. Taunton (diemuzi) on 2012-07-02T14:36:30.000+0000

Just a minor update, testing from a view script in the Application Module (which is where the layout exists) and the same problem exists here.

It seems the only place where append/prepend works is in the layout.phtml file. Otherwise regardless which option you use it will always place the JS or CSS file above the current headScript() from the layout.

Posted by Matthew Weier O'Phinney (matthew) on 2012-07-02T15:51:53.000+0000

The layout view script is executed last in the chain -- all other child view scripts are executed first. If you switch your layout view script to use prepend() instead, you'll get the behavior you want.

Have you found an issue?

See the Overview section for more details.


© 2006-2018 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.