Re: How do I use the JS-file caching mechanism of Horde?
Jan Schneider <[email protected]> Thu, 23 Nov 2017 16:38:22 +0000
| Newsgroups | gmane.comp.horde.devel |
|---|---|
| Message-ID | <[email protected]> |
Zitat von Sebastian Birnbach <[email protected]>: > Followup: > > > I meanwhile figured out the official method for adding JS files: > Horde_PageOutput::addScriptFile(). > > Still, I can't seem to make it work. > > > Everything works when the Horde_View file contains > > <script type="text/javascript" src="/js/form_sections.js"></script> > > But if I replace that with > > <?php > $GLOBALS['page_output']->addScriptFile('form_sections.js', 'horde'); > ?> > > I see that the generated HTML code loads a cached version of the js file: > > <script type="text/javascript" > src="/js/form_sections.js?v=596ca0a81b7fe741719c6df2f8b52a22"></script> > > only that functionality is negative. > > > In this case, JS console complains about undefined variable > sections_dossier_form > which is in fact defined near the bottom of the Horde_View file: > > <script type="text/javascript">//<![CDATA[ > var sections_dossier_form = new Horde_Form_Sections('dossier_form', > 'overview'); > document.observe("dom:loaded",function(){$("horde_form").focusFirstElement();}); > //]]></script> > > Any clues, anybody? > > 2017-11-23 9:35 GMT+01:00 Sebastian Birnbach <[email protected]>: > >> I am playing around with Horde_Views and the Javascript gems in /js, like >> tables.js or form_sections.js. It is a real pity that there is so little >> documentation (none at all?) on these. >> >> Anyway, I am wondering how to include JS files making use of the Horde JS >> caching system. For instance, I see in the HTML source of an average Horde >> page something like >> >> <script type="text/javascript" >> src="/js/prototype.js?v=596ca0a81b7fe741719c6df2f8b52a22 >> >> and I assume that the v=... is a caching key. What would be the proper way >> to get such a key and denote inclusion of a JS file in a Horde_View with >> caching support? >> You need to call addScriptFile() *before* starting the page output. -- Jan Schneider The Horde Project https://www.horde.org/ -- dev mailing list Frequently Asked Questions: http://wiki.horde.org/FAQ To unsubscribe, mail: [email protected]