21487 Posts in 5783 Topics by 2621 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1014 Views |
-
Requirements::javascript loading js files twice

18 July 2011 at 2:45am
I am trying to use Requirements::javascript to load in my .js files. For some reason silverstripe is loading all the files twice any time I use Requirements::javascript.
Has anyone else experienced this?
Here is my code:
function init() {
$themePath = 'themes/' . SSViewer::current_theme() . '/';
Requirements::javascript($themePath . 'js/JAIL.js');
parent::init();
}I'm getting the same result when I try to use Requirements in page.php as well.
Thanks!
-
Re: Requirements::javascript loading js files twice

19 July 2011 at 4:39am
2 things to try...
1) move the parent::init to the beginning of the function
2) add a Debug::show('test') to ensure that the code is only called once -
Re: Requirements::javascript loading js files twice

19 July 2011 at 4:39am
2 things to try...
1) move the parent::init to the beginning of the function
2) add a Debug::show('test') to ensure that the code is only called once -
Re: Requirements::javascript loading js files twice

19 July 2011 at 9:18am
thanks swaiba.
I added a Debug test and it seemed to confirm that Page_Controller was only being called once. I also added the parent::init call at the top of the function, but still having the same issue. Any files inserted into the page through the Requirements::javascript method are being added twice - Requirements::customScript, Requirements::javascript, etc. Oddly, Requirements::css is not exhibiting the same behavior.
All other elements of my footer are only being inserted once (</body>, </html>, etc) so I don't think it is a matter of including my Footer twice.
Any other thoughts?
Thanks again!
-
Re: Requirements::javascript loading js files twice

21 July 2011 at 2:21am
Oddly enough, I removed my html5 <header> element in my header and replaced it <div id="header"> and that stopped the double inclusion of Requirements::javascript files.
-
Re: Requirements::javascript loading js files twice

23 December 2011 at 5:27am
See https://github.com/silverstripe/sapphire/pull/143 for fix.
| 1014 Views | ||
|
Page:
1
|
Go to Top |


