21288 Posts in 5733 Topics by 2602 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1265 Views |
-
Requirements - changing JS loading order.

28 April 2009 at 3:58pm
I've come across an issue where the order in which prototype and jQuery are loaded cause issues. In the CMS, prototype is called first, then jQuery kindly lets it do its thing by running with noConflict.
However, I'm trying to use a TabSets outside of the CMS and for some reason unknown, jQuery is appearing before prototype. This causes prototype to semi-fail. Validators don't work properly, I get errors like "$ is not a function" etc. I guess it isn't surprising considering that TabSet loads the entire jQuery library just so it can use livequery, but uses prototype for all it's internal logic in (tabstrip.js).
I mean, surely whoever wrote this in TabSet.php felt a little bit dirty
public function FieldHolder() {
Requirements::javascript(THIRDPARTY_DIR . "/loader.js");
Requirements::javascript(THIRDPARTY_DIR . "/prototype.js");
Requirements::javascript(THIRDPARTY_DIR . "/behaviour.js");
Requirements::javascript(THIRDPARTY_DIR . "/prototype_improvements.js");
Requirements::javascript(THIRDPARTY_DIR . "/jquery/jquery.js");
Requirements::javascript(THIRDPARTY_DIR . "/jquery/jquery_improvements.js");
Requirements::javascript(THIRDPARTY_DIR . '/jquery/plugins/livequery/jquery.livequery.js');
Requirements::javascript(THIRDPARTY_DIR . "/tabstrip/tabstrip.js");
Requirements::css(THIRDPARTY_DIR . "/tabstrip/tabstrip.css");
return $this->renderWith("TabSetFieldHolder");
}Anyway, is there any way for force javascript requirements to appear in a particular order. Since prototype refuses to play nicely, it is up to jQuery to save the day by loading second. Any tips appreciated.
Regards,
Hamish -
Re: Requirements - changing JS loading order.

28 April 2009 at 4:02pm
By the way, I found out it was the loading order by copying the generated source into a static page, then swapped the scripts around. Simply moving prototype before jquery fixes the problem.
-
Re: Requirements - changing JS loading order.

28 April 2009 at 4:13pm
Ok, found where jQuery was being loaded and preceded it with a requrements all for prototype. So now I have to load prototype every time I want to juse jQuery, on the off-chance that something else will try to load prototype later. Makes jQuery seem a little pointless :/
-
Re: Requirements - changing JS loading order.

11 May 2009 at 12:50pm
Could you post your code for this? I'm having real problems getting jquery and prototype to play nicely.
| 1265 Views | ||
|
Page:
1
|
Go to Top |


