Chris Smith wrote:
On thinking about this some more, it may not work properly for syntax plugins. The wiki page is rendered after TPL_METAHEADERS_OUTPUT event has been triggered. This could mean the js is out of step from the page by one visit. Ie. it won't have the javascript the first time the page is viewed after adding the syntax and it will have the javascript one more time after the syntax has been removed from the page.Martin Tschofen wrote:Yes. Subscribe to the "TPL_METAHEADERS_OUTPUT" event. You can add to the event data, information used to construct <script></script> tags for inclusion within the page's <head> ... </head> block.If I have a plugin that adds a javascript event, does this event get called on every page (that's what it looks like) or just when the plugin (it's syntax) was used? How can I control that? Is it possible to only trigger the js event when I use the plugin on a page? I'm noticing some performance issues on some older computers and hope that this can be controlled. Thanks...martin
For the googlemaps plugin, the first time some google map syntax is encountered, I include a script element in the page to load the (external) google map javascript. Each piece of google map syntax also generates its own script element which sets javascript variables. The plugin has its own javascript file included on every page - however the first line of its setup is a check to see if there are any googlemaps javascript variables set. If there aren't any, it exits straight away.
Cheers, Chris -- DokuWiki mailing list - more info at http://wiki.splitbrain.org/wiki:mailinglist