Go Back   CodingForums.com > :: Client side development > JavaScript programming > JavaScript frameworks

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-17-2012, 08:58 AM   PM User | #1
tabbu
New to the CF scene

 
Join Date: Jul 2012
Posts: 9
Thanks: 1
Thanked 0 Times in 0 Posts
tabbu is an unknown quantity at this point
multiple jquery slideshows on one page

Hello,

I'm trying to add two slide shows on to a page using a jquery plugin. I've tried a number of ways to do this without success, can anyone give me a solution to this problem?

Code:
<script>
		$(function(){
			$('#slides').slides({
				preload: true,
				preloadImage: 'img/loading.gif',
				play: 5000,
				pause: 2500,
				hoverPause: true,
				animationStart: function(current){
					$('.caption').animate({
						bottom:-35
					},100);
					if (window.console && console.log) {
						// example return of current slide number
						console.log('animationStart on slide: ', current);
					};
				},
				animationComplete: function(current){
					$('.caption').animate({
						bottom:0
					},200);
					if (window.console && console.log) {
						// example return of current slide number
						console.log('animationComplete on slide: ', current);
					};
				},
				slidesLoaded: function() {
					$('.caption').animate({
						bottom:0
					},200);
				}
			});
		});
	</script>
I've tried to recreate the above code by changing the class and div id names but this didn't work either. I'm also using the slides.min.jquery.js plugin.

Thanks for any solutions to this.

Last edited by VIPStephan; 12-17-2012 at 10:49 AM.. Reason: fixed code BB tag
tabbu is offline   Reply With Quote
Old 12-17-2012, 10:54 AM   PM User | #2
VIPStephan
The fat guy next door


 
VIPStephan's Avatar
 
Join Date: Jan 2006
Location: Halle (Saale), Germany
Posts: 7,583
Thanks: 5
Thanked 864 Times in 841 Posts
VIPStephan is a jewel in the roughVIPStephan is a jewel in the roughVIPStephan is a jewel in the rough
Well, the code has selectors that are too general. For example, if you have several slideshows, how should it know which .caption to address if all it say is “address the element with class .caption, anywhere in the document”? Either you copy the function and change the selectors for each specific slideshow or you work with the each() function, like:
Code:
$('.slides').each(function() {
  var el = $(this);
  var caption = el.find('.caption');
  el.slides({
    …
    (your slider code here)
    …
  });
// everytime when $('.caption').animate() occurs it should be replaced with the variable defined above, i. e. caption.animate()
});
__________________
Don’t click this link!

Last edited by VIPStephan; 12-17-2012 at 10:57 AM..
VIPStephan is online now   Reply With Quote
Users who have thanked VIPStephan for this post:
tabbu (12-17-2012)
Old 12-17-2012, 11:26 AM   PM User | #3
tabbu
New to the CF scene

 
Join Date: Jul 2012
Posts: 9
Thanks: 1
Thanked 0 Times in 0 Posts
tabbu is an unknown quantity at this point
Ok solution found, and it was staring me in the face and way too easy, how silly this javaScript malarkey is.

Thanks for your swift reply.

What i did is copied the entire code and added:

$(function(){
$('#slides_two').slides({

Then added the #slides_two id to html and css put in my styling and hey presto it all works, probably not the most elegant solution but it works.

Yours seems far more elegant and efficient.
Thanks again.

Last edited by tabbu; 12-17-2012 at 11:30 AM..
tabbu is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT +1. The time now is 07:17 PM.


Advertisement
Log in to turn off these ads.