Ir para conteúdo

POWERED BY:

Arquivado

Este tópico foi arquivado e está fechado para novas respostas.

logan_pa

Slider JQuery não funciona

Recommended Posts

Estou tentando usar 2x o mesmo slider na página mas não funciona. Apenas funciona o primeiro. As imagens não aparecem quando duplico o html.

 

 

Abaixo o código que estou usando:

 

$(function(){
			$('#slides2').slides2({
				preload: true,
				preloadImage: 'img/loading.gif',
				play: 0,
				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);
				}
			});
		});

 

<div id="slides2">
	<!-- Seta esquerda -->
	<div class="botao-esquerdo2">
		<a href="#" class="prev2"><img src="img/arrow-prev2.png" alt="Arrow Prev" border="0" /></a>
	</div>
	<!-- Seta esquerda -->
	
	<!-- Fotos --> 
	<div class="slides_container2">
	<div class="slide2">
		<a href="#"><img src="img/01.jpg" alt="fotos" /></a>
	</div>
	<div class="slide2">
		<a href="#"><img src="img/02.jpg" alt="fotos" /></a>
	</div>
	<div class="slide2">
		<a href="#"><img src="img/03.jpg" alt="fotos" /></a>
	</div>
	<!-- Fotos --> 

	<!-- Seta direita --> 
	<div class="botao-direito2">
		<a href="#" class="next2"><img src="img/arrow-next2.png" alt="Arrow Next" border="0" /></a>
	</div>
	<!-- Seta direita -->
</div>
</div>

			
	

 

 

Compartilhar este post


Link para o post
Compartilhar em outros sites

Ambos tem mesmo ID??

 

Se tiverem tenta duplicar o codigo do slider deixa um com um id e outro com outro, mesma coisa nas divs. :)

Já tentei, não funcionou.

 

 

$('#slides2').slides({

Se entendi bem vc sugere usar nomes diferentes também? Se for isso já tentei infelizmente não deu certo.

Compartilhar este post


Link para o post
Compartilhar em outros sites

não, vc não entendeu.

 

poste o seu script completo.

Compartilhar este post


Link para o post
Compartilhar em outros sites

não, vc não entendeu.

 

poste o seu script completo.

 

setas-sliders.js

$(function(){
			$('#slides2').slides2({
				preload: true,
				preloadImage: 'img/loading.gif',
				play: 0,
				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);
				}
			});
		});

 

slides.min.jquery2.js

/*
* Slides, A Slideshow Plugin for jQuery
* Intructions: http://slidesjs.com
* By: Nathan Searles, http://nathansearles.com
* Version: 1.1.9
* Updated: September 5th, 2011
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
(function(a){a.fn.slides2=function(b){return b=a.extend({},a.fn.slides2.option,b),this.each(function(){function w(g,h,i){if(!p&&o){p=!0,b.animationStart(n+1);switch(g){case"next2":l=n,k=n+1,k=e===k?0:k,r=f*2,g=-f*2,n=k;break;case"prev2":l=n,k=n-1,k=k===-1?e-1:k,r=0,g=0,n=k;break;case"pagination2":k=parseInt(i,10),l=a("."+b.pagination2Class+" li."+b.currentClass+" a",c).attr("href").match("[^#/]+$"),k>l?(r=f*2,g=-f*2):(r=0,g=0),n=k}h==="fade"?b.crossfade?d.children(":eq("+k+")",c).css({zIndex:10}).fadeIn(b.fadeSpeed,b.fadeEasing,function(){b.autoHeight?d.animate({height:d.children(":eq("+k+")",c).outerHeight()},b.autoHeightSpeed,function(){d.children(":eq("+l+")",c).css({display:"none",zIndex:0}),d.children(":eq("+k+")",c).css({zIndex:0}),b.animationComplete(k+1),p=!1}):(d.children(":eq("+l+")",c).css({display:"none",zIndex:0}),d.children(":eq("+k+")",c).css({zIndex:0}),b.animationComplete(k+1),p=!1)}):d.children(":eq("+l+")",c).fadeOut(b.fadeSpeed,b.fadeEasing,function(){b.autoHeight?d.animate({height:d.children(":eq("+k+")",c).outerHeight()},b.autoHeightSpeed,function(){d.children(":eq("+k+")",c).fadeIn(b.fadeSpeed,b.fadeEasing)}):d.children(":eq("+k+")",c).fadeIn(b.fadeSpeed,b.fadeEasing,function(){a.browser.msie&&a(this).get(0).style.removeAttribute("filter")}),b.animationComplete(k+1),p=!1}):(d.children(":eq("+k+")").css({left:r,display:"block"}),b.autoHeight?d.animate({left:g,height:d.children(":eq("+k+")").outerHeight()},b.slideSpeed,b.slideEasing,function(){d.css({left:-f}),d.children(":eq("+k+")").css({left:f,zIndex:5}),d.children(":eq("+l+")").css({left:f,display:"none",zIndex:0}),b.animationComplete(k+1),p=!1}):d.animate({left:g},b.slideSpeed,b.slideEasing,function(){d.css({left:-f}),d.children(":eq("+k+")").css({left:f,zIndex:5}),d.children(":eq("+l+")").css({left:f,display:"none",zIndex:0}),b.animationComplete(k+1),p=!1})),b.pagination2&&(a("."+b.pagination2Class+" li."+b.currentClass,c).removeClass(b.currentClass),a("."+b.pagination2Class+" li:eq("+k+")",c).addClass(b.currentClass))}}function x(){clearInterval(c.data("interval"))}function y(){b.pause?(clearTimeout(c.data("pause")),clearInterval(c.data("interval")),u=setTimeout(function(){clearTimeout(c.data("pause")),v=setInterval(function(){w("next2",i)},b.play),c.data("interval",v)},b.pause),c.data("pause",u)):x()}a("."+b.container,a(this)).children().wrapAll('<div class="slides_control"/>');var c=a(this),d=a(".slides_control",c),e=d.children().size(),f=d.children().outerWidth(),g=d.children().outerHeight(),h=b.start-1,i=b.effect.indexOf(",")<0?b.effect:b.effect.replace(" ","").split(",")[0],j=b.effect.indexOf(",")<0?i:b.effect.replace(" ","").split(",")[1],k=0,l=0,m=0,n=0,o,p,q,r,s,t,u,v;if(e<2)return a("."+b.container,a(this)).fadeIn(b.fadeSpeed,b.fadeEasing,function(){o=!0,b.slidesLoaded()}),a("."+b.next2+", ."+b.prev2).fadeOut(0),!1;if(e<2)return;h<0&&(h=0),h>e&&(h=e-1),b.start&&(n=h),b.randomize&&d.randomize(),a("."+b.container,c).css({overflow:"hidden",position:"relative"}),d.children().css({position:"absolute",top:0,left:d.children().outerWidth(),zIndex:0,display:"none"}),d.css({position:"relative",width:f*3,height:g,left:-f}),a("."+b.container,c).css({display:"block"}),b.autoHeight&&(d.children().css({height:"auto"}),d.animate({height:d.children(":eq("+h+")").outerHeight()},b.autoHeightSpeed));if(b.preload&&d.find("img:eq("+h+")").length){a("."+b.container,c).css({background:"url("+b.preloadImage+") no-repeat 50% 50%"});var z=d.find("img:eq("+h+")").attr("src")+"?"+(new Date).getTime();a("img",c).parent().attr("class")!="slides_control"?t=d.children(":eq(0)")[0].tagName.toLowerCase():t=d.find("img:eq("+h+")"),d.find("img:eq("+h+")").attr("src",z).load(function(){d.find(t+":eq("+h+")").fadeIn(b.fadeSpeed,b.fadeEasing,function(){a(this).css({zIndex:5}),a("."+b.container,c).css({background:""}),o=!0,b.slidesLoaded()})})}else d.children(":eq("+h+")").fadeIn(b.fadeSpeed,b.fadeEasing,function(){o=!0,b.slidesLoaded()});b.bigTarget&&(d.children().css({cursor:"pointer"}),d.children().click(function(){return w("next2",i),!1})),b.hoverPause&&b.play&&(d.bind("mouseover",function(){x()}),d.bind("mouseleave",function(){y()})),b.generateNextPrev&&(a("."+b.container,c).after('<a href="#" class="'+b.prev2+'">Prev</a>'),a("."+b.prev2,c).after('<a href="#" class="'+b.next2+'">Next</a>')),a("."+b.next2,c).click(function(a){a.preventDefault(),b.play&&y(),w("next2",i)}),a("."+b.prev2,c).click(function(a){a.preventDefault(),b.play&&y(),w("prev2",i)}),b.generatePagination2?(b.prependPagination2?c.prepend("<ul class="+b.pagination2Class+"></ul>"):c.append("<ul class="+b.pagination2Class+"></ul>"),d.children().each(function(){a("."+b.pagination2Class,c).append('<li><a href="#'+m+'">'+(m+1)+"</a></li>"),m++})):a("."+b.pagination2Class+" li a",c).each(function(){a(this).attr("href","#"+m),m++}),a("."+b.pagination2Class+" li:eq("+h+")",c).addClass(b.currentClass),a("."+b.pagination2Class+" li a",c).click(function(){return b.play&&y(),q=a(this).attr("href").match("[^#/]+$"),n!=q&&w("pagination2",j,q),!1}),a("a.link",c).click(function(){return b.play&&y(),q=a(this).attr("href").match("[^#/]+$")-1,n!=q&&w("pagination2",j,q),!1}),b.play&&(v=setInterval(function(){w("next2",i)},b.play),c.data("interval",v))})},a.fn.slides2.option={preload:!1,preloadImage:"/img/loading.gif",container:"slides_container2",generateNextPrev:!1,next2:"next2",prev2:"prev2",pagination2:!0,generatePagination2:!0,prependPagination2:!1,pagination2Class:"pagination2",currentClass:"current",fadeSpeed:350,fadeEasing:"",slideSpeed:350,slideEasing:"",start:1,effect:"slide2",crossfade:!1,randomize:!1,play:0,pause:0,hoverPause:!1,autoHeight:!1,autoHeightSpeed:350,bigTarget:!1,animationStart:function(){},animationComplete:function(){},slidesLoaded:function(){}},a.fn.randomize=function(b){function c(){return Math.round(Math.random())-.5}return a(this).each(function(){var d=a(this),e=d.children(),f=e.length;if(f>1){e.hide();var g=[];for(i=0;i<f;i++)g[g.length]=i;g=g.sort(c),a.each(g,function(a,c){var f=e.eq(c),g=f.clone(!0);g.show().appendTo(d),b!==undefined&&b(f,g),f.remove()})}})}})(jQuery)

Compartilhar este post


Link para o post
Compartilhar em outros sites

assim q vc duplicar o html, vc precisa trocar o ID do elemento duplicado, fazendo assim 2 chamadas ao plugin:

$('#slides2').slides2({
e,
$('#slides3').slides2({

Compartilhar este post


Link para o post
Compartilhar em outros sites

 

assim q vc duplicar o html, vc precisa trocar o ID do elemento duplicado, fazendo assim 2 chamadas ao plugin:

$('#slides2').slides2({
e,
$('#slides3').slides2({

 

Não altero nada nos dois js? deixo como está?

Compartilhar este post


Link para o post
Compartilhar em outros sites

×

Informação importante

Ao usar o fórum, você concorda com nossos Termos e condições.