22847 Posts in 9642 Topics by 2802 members
|Go to End|
7 September 2013 at 3:07am
How do I prevent Requirements from loading scripts twice?
http://doc.silverstripe.org/framework/en/reference/requirements the script is added to the end of the HTML twice. This causes any triggers to be fired twice.
I found one forum post which says double loading was fixed in version 2.4
This was slightly different as it was loading in the <head> and <header>, rather than twice at the end of the <body>
Another forum post
which says a similar issue was fixed in the SS 3.1. There is no SS 3.1 on the downloads page.
On a side note, I find the current search function, which appears to be embedded Google results, frustrating compared to the old forum search. The previous setup gave much more targeted results. One could get either specific forum search results using the internal search, or use Google as a second method.
7 September 2013 at 3:26am
Dunno what you're actually doing, maybe you've the same script twice in your code.
However you can try the second parameter $uniquenessID of customScript().
Requirements::customScript("alert('no one');", 'myUniqueID');
7 September 2013 at 3:34am
Thanks for your quick reply!
I found the undocumented $uniquenessID digging through the source code after I posted. I put a random number in the string and it worked. It's probably smart to use a string that's descriptive of the script so one doesn't accidentally use the same ID twice for different scripts.
|Go to Top|