Jump to:

23371 Posts in 18161 Topics by 2865 members

General Questions

SilverStripe Forums » General Questions » [SOLVED] Requirements::javascript latches on to inline javascript

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: 436 Views
  • jizzman
    Avatar
    Community Member
    23 Posts

    [SOLVED] Requirements::javascript latches on to inline javascript Link to this post

    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

  • simon_w
    Avatar
    Forum Moderator
    471 Posts

    Re: [SOLVED] Requirements::javascript latches on to inline javascript Link to this post

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

  • jizzman
    Avatar
    Community Member
    23 Posts

    Re: [SOLVED] Requirements::javascript latches on to inline javascript Link to this post

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

    436 Views
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.