Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Closed Thread
Old 03-02-2011, 10:16 AM jQuery Conflicts!
edgray's Avatar
Super Moderator

Latest Blog Post:
Frantic
Posts: 4,264
Name: Sugarcane Gray
Location: Hell, Southern Spain
Trades: 0
I'm working on a site right now that has a jQuery carousel and a jQuery lightbox (colorbox) for login purposes.

I can't get them to both work. It seems like the one that's called last in the document head works, the first one doesn't. The head code is:

HTML Code:
	<head>
		<title>**** // Jeans and Stuff</title>
		<link href="css/reset.css" type="text/css" rel="stylesheet" media="screen"/>			
		<link href="css/styles.css" type="text/css" rel="stylesheet" media="screen"/>
		<link href="css/slider.css" type="text/css" rel="stylesheet" media="screen"/>						
		
                <!-- colorbox -->
                <link media="screen" rel="stylesheet" href="css/colorbox.css" />
		<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js"></script>
		<script src="js/jquery.colorbox.js"></script>
		<script>
			$(document).ready(function(){
				//Examples of how to assign the ColorBox event to elements

				$(".login").colorbox();				
			
			});
		</script>
            <!-- carousel -->
	    <script src="js/jquery-1.2.6.js" type="text/javascript" charset="utf-8"></script> 
	    <script src="js/jquery-ui-full-1.5.2.min.js" type="text/javascript" charset="utf-8"></script>	
	    <script type="text/javascript" charset="utf-8"> 
    	    window.onload = function () {
    	        var container = $('div.sliderGallery');
       	     var ul = $('ul', container);
       	     
       	     var itemsWidth = ul.innerWidth() - container.outerWidth();
       	     
       	     $('.slider', container).slider({
       	         min: 0,
       	         max: itemsWidth,
       	         handle: '.handle',
       	         stop: function (event, ui) {
       	             ul.animate({'left' : ui.value * -1}, 500);
       	         },
       	         slide: function (event, ui) {
       	             ul.css('left', ui.value * -1);
       	         }
       	     });
       	 };
    	</script> 				
	</head>
So in the above example, the carousel works but the colorbox doesn't. When I put the colorbox code underneath the carousel, that works, but the carousel remains annoyingly static.

being no expert in javascript, I'm stuck. I have a hunch it's something to do with the differing versions of jQuery the two scripts are calling. Am I right or totally off here?

Any help would be much appreciated.
__________________

Please login or register to view this content. Registration is FREE
- a project in video and sound.

Please login or register to view this content. Registration is FREE
"Absolute Rubbish, an insult to the blues." - NME.

Please login or register to view this content. Registration is FREE
- Come use our agency :)

Last edited by edgray; 03-02-2011 at 10:18 AM..
edgray is offline
View Public Profile Visit edgray's homepage!
 
 
Register now for full access!
Old 03-02-2011, 01:14 PM Re: jQuery Conflicts!
Extreme Talker

Posts: 246
Trades: 0
Move the script tags with the colorbox code below where you declare the external js files.

Also, you will have a ton of conflicts if you use two different versions of jQuery in the same page. Try removing the reference to jQuery 1.2 and see if the code works, or see if there is a newer version of the control that works with 1.4.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
stbuchok is offline
View Public Profile
 
Old 03-02-2011, 02:31 PM Re: jQuery Conflicts!
edgray's Avatar
Super Moderator

Latest Blog Post:
Frantic
Posts: 4,264
Name: Sugarcane Gray
Location: Hell, Southern Spain
Trades: 0
Quote:
Originally Posted by stbuchok View Post
Move the script tags with the colorbox code below where you declare the external js files.

Also, you will have a ton of conflicts if you use two different versions of jQuery in the same page. Try removing the reference to jQuery 1.2 and see if the code works, or see if there is a newer version of the control that works with 1.4.
I thought it might be a conflict between the two versions of jQuery. Thanks, I'll give this a go.
__________________

Please login or register to view this content. Registration is FREE
- a project in video and sound.

Please login or register to view this content. Registration is FREE
"Absolute Rubbish, an insult to the blues." - NME.

Please login or register to view this content. Registration is FREE
- Come use our agency :)
edgray is offline
View Public Profile Visit edgray's homepage!
 
Old 03-03-2011, 08:35 AM Re: jQuery Conflicts!
edgray's Avatar
Super Moderator

Latest Blog Post:
Frantic
Posts: 4,264
Name: Sugarcane Gray
Location: Hell, Southern Spain
Trades: 0
I ended up adding this line to the carousel:

Code:
var J = jQuery.noConflict();
and then changing all of the "$" references to "J"
__________________

Please login or register to view this content. Registration is FREE
- a project in video and sound.

Please login or register to view this content. Registration is FREE
"Absolute Rubbish, an insult to the blues." - NME.

Please login or register to view this content. Registration is FREE
- Come use our agency :)
edgray is offline
View Public Profile Visit edgray's homepage!
 
Old 03-03-2011, 03:26 PM Re: jQuery Conflicts!
Extreme Talker

Posts: 246
Trades: 0
so when you do that which version of jQuery is it applying to, the 1.2 version or the 1.4 version.
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
stbuchok is offline
View Public Profile
 
Closed Thread     « Reply to jQuery Conflicts!
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.15427 seconds with 12 queries