You will recieve your password to this address. Address is not made public.

Your preferred username that is used when logging in.

jQuery tools must be loaded right after jQuery Created Sep 30, 2009

This thread is solved

Views: 2445     Replies: 6     Last reply Oct 6, 2009  
You must login first before you can use this feature

RSpace

Posts: 3

Registered:
Sep 30, 2009

jQuery tools must be loaded right after jQuery

Posted: Sep 30, 2009

I love jQuery Tools and Flowplayer, but they are not the only jQuery libraries I use. Namely I like to use jQuery UI, and often many of the great plugins written for jQuery.

However, jQuery UI and other jQuery plugins can only be used together with jQuery Tools, if tools are loaded right after jQuery.

This works:


<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
<script src="http://cdn.jquerytools.org/1.1.1/jquery.tools.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js" type="text/javascript"></script>

This does not work:


<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js" type="text/javascript"></script>
<script src="http://cdn.jquerytools.org/1.1.1/jquery.tools.min.js" type="text/javascript"></script>

In the latter example where jQuery Tools is loaded after jQuery UI, none of the UI methods will be available, like UI was never loaded in the first place. It seems Tools load in a way that overrides methods add to jQuery by other plugins.

I have been bitten by this bug several times now, so even if it's not fixed, at least other people hopefully will stumble upon this solution.

Here is the full test page:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml2/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Test</title>
		<link type="text/css" href="http://jqueryui.com/latest/themes/base/ui.all.css" rel="stylesheet" />
		<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
		<script src="http://cdn.jquerytools.org/1.1.1/jquery.tools.min.js" type="text/javascript"></script>
		<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js" type="text/javascript"></script>
		<script type="text/javascript">
	    $(function() {
				$('#test_element').slider();
			});
	  </script>
	</head>
	<body>
		<div id="test_element"></div>
	</body>
</html>

Try switching the load order of Tools and UI, and test_element is no longer made into a slider - instead we get a javascript error.

Tero
Author of jQuery Tools and this website + JavaScript developer of Flowplayer.

Posts: 1867

Registered:
Nov 16, 2007

» jQuery tools must be loaded right after jQuery

Posted: Sep 30, 2009

Reply to: jQuery tools must be loaded right after jQuery, from RSpace
what happens if you dont use the tabs plugin? that is the only name conflict on those libraries.

RSpace

Posts: 3

Registered:
Sep 30, 2009

» » jQuery tools must be loaded right after jQuery

Posted: Oct 5, 2009

Reply to: » jQuery tools must be loaded right after jQuery, from tipiirai
Hi Tero,

I do not believe the problem has anything to do with jQuery UI specifically, I just used that library as an example because it's very common.

I get the exact same problem without jQuery UI, when I try to load another jQuery plugin before jQuery Tools. For instance the Metadata plugin:

This works:


<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
<script src="http://cdn.jquerytools.org/1.1.1/jquery.tools.min.js" type="text/javascript"></script>
<script src="http://darebusters.com/javascripts/jquery-plugins/jquery.metadata.js" type="text/javascript"></script>

This does not work:


<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
<script src="http://darebusters.com/javascripts/jquery-plugins/jquery.metadata.js" type="text/javascript"></script>
<script src="http://cdn.jquerytools.org/1.1.1/jquery.tools.min.js" type="text/javascript"></script>

The metadata plugin code is loaded, but it's methods is not available - again like they have been overwritten/removed by jQuery Tools.

Here is the full test page:


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml2/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Test</title>
		<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js" type="text/javascript"></script>
		<script src="http://darebusters.com/javascripts/jquery-plugins/jquery.metadata.js" type="text/javascript"></script>
		<script src="http://cdn.jquerytools.org/1.1.1/jquery.tools.min.js" type="text/javascript"></script>
		<script type="text/javascript">
	    $(function() {
				$('#test_element').metadata();
			});
	  </script>
	</head>
	<body>
		<div id="test_element"></div>
	</body>
</html>

Tero
Author of jQuery Tools and this website + JavaScript developer of Flowplayer.

Posts: 1867

Registered:
Nov 16, 2007

» » » jQuery tools must be loaded right after jQuery

Posted: Oct 5, 2009

Reply to: » » jQuery tools must be loaded right after jQuery, from RSpace
I think I got this solved. The jquery.tools library already contains the jQuery library so there is no need to load it (again) from googleapis. If you want to use googleapis then you should use the minimal version:

http://cdn.jquerytools.org/1.1.1/tiny/jquery.tools.min.js

By using this tiny version the metadata (or any other library) can be loaded before or after the tools. Look for more information on the download page:

http://flowplayer.org/tools/download.html

Tero
Author of jQuery Tools and this website + JavaScript developer of Flowplayer.

Posts: 1867

Registered:
Nov 16, 2007

» » » » jQuery tools must be loaded right after jQuery

Posted: Oct 5, 2009

Reply to: » » » jQuery tools must be loaded right after jQuery, from tipiirai
(a random test post here - something weird with the forums...)

RSpace

Posts: 3

Registered:
Sep 30, 2009

» » » » jQuery tools must be loaded right after jQuery

Posted: Oct 5, 2009

Reply to: » » » jQuery tools must be loaded right after jQuery, from tipiirai
Yes, that was it. Makes perfect sense that re-including jQuery will remove previously loaded plugins. Perhaps you could make it more clear that certain versions of jQuery tools include jQuery - I certainly wasn't aware of it, and this is not even the first site I use Tools for.

Thank you for your help and for making a great library :)

Tero
Author of jQuery Tools and this website + JavaScript developer of Flowplayer.

Posts: 1867

Registered:
Nov 16, 2007

» » » » » jQuery tools must be loaded right after jQuery

Posted: Oct 6, 2009

Reply to: » » » » jQuery tools must be loaded right after jQuery, from RSpace
OK. Thanks for the tip. I think that at least the donwload page says this pretty clearly:

http://flowplayer.org/tools/download.html