Skip to main content

This site requires you to update your browser. Your browsing experience maybe affected by not having the most up to date version.

We've moved the forum!

Please use forum.silverstripe.org for any new questions (announcement).
The forum archive will stick around, but will be read only.

You can also use our Slack channel or StackOverflow to ask for help.
Check out our community overview for more options to contribute.

General Questions /

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

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

[SOLVED] Requirements::javascript latches on to inline javascript


Go to End


3 Posts   1237 Views

Avatar
jizzman

Community Member, 23 Posts

4 March 2012 at 5:20pm

Hi,

I'm using 2.4.6. Normally the javascript appears at the bottom of the document. But I noticed an odd thing with a HTML page that has some inline javascript. The javascript files included via the Requirements::javascript() - called in the Page_Controller::init() - end up inserted just before my last piece of inline javascript. Certainly not what I was expecting. To work around this I have used the flag Requirements::set_write_js_to_body(false) in _config.php to force the javascript to the top. Note: the javascript is being generated inline by a PHP method. Expected behaviour or bug?

Thanks,
J

Avatar
(deleted)

Community Member, 473 Posts

4 March 2012 at 8:43pm

That's expected as there's no way to know if the inline javascript relies on something being included or not.

Avatar
jizzman

Community Member, 23 Posts

5 March 2012 at 11:49am

That shows my lack of web dev. experience! Thanks Simon.