Jump to:

2012 Posts in 1438 Topics by 621 members

Form Questions

SilverStripe Forums » Form Questions » js script inserted via Requirements::javascript doesn't work

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

Page: 1
Go to End
Author Topic: 398 Views
  • robbie.munger
    Avatar
    Community Member
    4 Posts

    js script inserted via Requirements::javascript doesn't work Link to this post

    I have inherited a SilverStripe project that I am cleaning up. Ext JS is used and therefor included in multiple pages. I would like to load the script along with other common requirements in Page.php, as other pages inherit from here. In code I have

    class Page_Controller extends ContentController {
       function init() {
          parent::init();
          Requirements::set_write_js_to_body(false);
          Requirements::javascript('mysite/javascript/extjs.js');

    This produces in <head>

    <script type="text/javascript" src="http://localhost/websitename/index.php/mysite/javascript/extjs.js?m=1259182671"></script>

    but extjs.js doesn't seem to load, e.g. "flyout" menus depending on it don't appear

    If I include extjs.js directly in code with

    <script src="$ThemeDir/javascripts/extjs.js" type="text/javascript" charset="utf-8"></script>

    this produces in <head>

    <script src="themes/websitename/javascripts/extjs.js" type="text/javascript" charset="utf-8"></script>

    which does work.

    Though I have a "workaround" I am trying to understand SilverStripe and http/html better. So I would like to understand the problem before deciding how to structure this site. Can someone explain the difference in behavior? Thanks!

  • robbie.munger
    Avatar
    Community Member
    4 Posts

    Re: js script inserted via Requirements::javascript doesn't work Link to this post

    I see I included from two different places. extjs.js is in both places and I have tested both ways. I plan to remove one copy as part of cleanup. This is typical of state of site. As in, I am still asking for help.

    398 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.