21280 Posts in 5729 Topics by 2600 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1778 Views |
-
linked javascript order

14 April 2009 at 5:42am
hi,
in what order does ss link javascript files?
because in my page.ss i have:<% require javascript(xxx/jquery-1.3.2.min.js) %>
<% require javascript(xxx/ui.accordion.js) %>but when i test the page, ui.accordion.js is always linked bevor jquery...
thanks
-
Re: linked javascript order

28 July 2009 at 1:18pm
Can anyone provide insight into this? I'm having a problem with the javascript load order as well. I put my <% require javascript %> tag in my .ss file just before I need the functionality, but the included js file is being linked too early (it's being linked before jquery, which it depends on). So I can't use the library because it consistently loads before jquery.js.
-
Re: linked javascript order

29 July 2009 at 12:57pm Last edited: 6 August 2009 12:05pm
For the benefit of anyone else who has this problem:
Don't link to the javascript files from your templates. Instead, load them in the init() call in the relevant controller. For example:
public function init()
{
Requirements::javascript('path/to/jquery.js');
Requirements::javascript('path/to/library/that/requires/jquery/lib.js');
parent::init();
}That works for me, as now jquery is linked before the other libraries that depend on it.
UPDATE: This is not an all-purpose solution. This fixed one particular situation, but doesn't truly solve the underlying problem. If anyone can shed light on how to really control the load order it would be helpful.
| 1778 Views | ||
|
Page:
1
|
Go to Top |

