Jump to:

23486 Posts in 18995 Topics by 2878 members

General Questions

SilverStripe Forums » General Questions » dynamic javascript snippets

General questions about getting started with SilverStripe that don't fit in any of the categories above.

Moderators: martimiz, Sean, biapar, Willr, Ingo, swaiba, simon_w

Page: 1
Go to End
Author Topic: 1077 Views
  • martimiz
    Forum Moderator
    1086 Posts

    dynamic javascript snippets Link to this post

    I have this situation where I want to include some javascript depending on whether a specific template is included. I know I can use <% require javascript(... from within my templates, but there doesn't seem to be an equivalent for inline scripts, like <% require customScript(...

    I could enter the inline scripts 'manually' but I must use require for the files or Silverstripe will strip them away. Now SilverStripe seems to wait until the last <% require .. %> is found in the templates, and only then loads all files. This way an inline script added manually will sometimes precede the loading of the file it needs...

    So I can either create all my little inline scripts as files or call inline scripts from code. As I don't want to create code for these templates, this is not an option. Does this make sense to anyone? Did I overlook some way to add javascript snippets to a template so that Silverstripe will move them to the correct spot?

Page: 1
Go to Top

Want to know more about the company that brought you SilverStripe? Then check out SilverStripe.com

Comments on this website? Please give feedback.