I am currently loading parts of my site using ajax (jquery 1.x in a ZF2 app), which is working nicely, until i come to load a view that has dependent javascript/css files declared in the head of that view. Declaring setTerminal(true)
on the ViewModel only returns the content portion of the view, so any $this->headScript()->appendFile()
, $this->inlineScript()->appendFile()
and $this->headLink()->appendStylesheet()
files are not included.
This means that whilst the content is correctly loaded via ajax, it is not functional if there are additional scripts that need to be used in that view.
Is there an approach of including these files somehow, so that the ajax-requested content works?
As an example: Say i am developing a dashboard, that uses ajax to pull data from several different controllers, such as User information, Subscription information etc. In the dashboard i could just include all the javascript/css files that are defined in the User and Subscription views, but surely that is just polluting the Dashboard view with a lot of js/css files? There must be a better way.