Problem with Previous Slides 1


#1

var main=function(){
$('.dropdown-toggle').click(function(){
$('.dropdown-menu').toggle();
});

$('.arrow-next').click(function(){
    var currentSlide=$('.active-slide');
    var nextSlide=currentSlide.next();
    var currentDot =$('.active-dot');
    var nextDot=currentDot.next();
    if(nextSlide.length==0){
        nextSlide=$('.slide').first();
    }
    if(nextDot.length==0){
        nextDot=$('.dot').first();
    }
    currentSlide.fadeOut(600).removeClass('active-slide');
    nextSlide.fadeIn(600).addClass('active-slide');
    
    currentDot.removeClass('active-dot');
    nextDot.addClass('active-dot');
    });
    
$('.arrow-prev').click(function() {
var currentSlide = $('.active-slide');
var prevSlide = currentSlide.prev();

currentSlide.fadeOut(600).removeClass('active-slide');
prevSlide.fadeIn(600).addClass('active-slide');
});
}; 
$(document).ready(main);

this doesnt work. I get this: Oops, try again. It looks like previous arrow isn't moving back to the previous slide. Look back at the instructions and check the $('.arrow-prev').click() event handler

However, the webpage does go to the previous slide when the arrow-prev is clicked in the browser window.


#2

Hi @hp07,

Your code works fine for me. Could you try refreshing the page, please? :slight_smile:


#3

I have refreshed it, tried logging out and in again, reset and type again but it keeps giving the same response:
Oops, try again. It looks like previous arrow isn't moving back to the previous slide. Look back at the instructions and check the $('.arrow-prev').click() event handler

is it a bug?


#4

@hp07 Seems to be. When I run your code on this exercise, it passes me with no problems.

Perhaps you could try switching browsers?


#5

Tried it on Firefox and still no. I get the same message. Its frustrating to not be able to complete the course after 96% of progress


#6

@hp07 Hm :confused: Could you try resetting the exercise, running the default code once, then copy/pasting in your code from post #1 into the editor and running it again?


#7

Still to no avail. It doesnt pass me.


#8

@hp07 In that case, I have no clue what's wrong :frowning:

Your code is fine, and it works for me :confused:

Is it possible your browsers have an extension/addon that is causing problems?


#9

If there was a problem with the extensions, then all other exercises should be affected right? I was learning Ruby today without a problem.

Do you have any other code?


#10

@hp07

If there was a problem with the extensions, then all other exercises should be affected right?

It seems like that, but sometimes a certain exercise will check code in a way that none of the others do, and that will cause a problem, or sometimes a person will have installed a new extension halfway through the course and not realize it might be why they're not being passed.

Do you have any other code?

Answer-sharing isn't usually allowed on the forums, but I think this is one of those cases where it's OK, so here's my code:

Spoiler! (click to view)

var main = function() {
    $('.dropdown-toggle').click(function() {
        $('.dropdown-menu').toggle();
    });
    
    $('.arrow-next').click(function() {
        var currentSlide = $('.active-slide');
        var nextSlide = currentSlide.next();
        
        var currentDot = $('.active-dot');
        var nextDot = currentDot.next();
        
        if (nextSlide.length == 0) {
            nextSlide = $('.slide').first();
            nextDot = $('.dot').first();
        }
        
        currentSlide.fadeOut(600).removeClass('active-slide');
        nextSlide.fadeIn(600).addClass('active-slide');
        
        currentDot.removeClass('active-dot');
        nextDot.addClass('active-dot');
    });
    
    $('.arrow-prev').click(function() {
        var currentSlide = $('.active-slide');
        var prevSlide = currentSlide.prev();
        
        currentSlide.fadeOut(600).removeClass('active-slide');
        prevSlide.fadeIn(600).addClass('active-slide');
    });
};

$(document).ready(main);


#11

Thanks dude, but still doesn't solve a thing. I haven't installed any extensions for a while now. So what do I do? I hate to leave it at 96%.


#12

@hp07 I'm really not sure what's wrong here :frowning:

Could I get:

  • Your browser
  • Your operating system
  • Whether you're on a home, school, or company network
  • Whether any adblockers are active
  • A screenshot of the entire page with the error message showing

? Thanks!


#13

I am using Google Chrome Version 50.0.2661.102 m

My OS is Windows 7 Professional - 64 bit

Im on my home network at home.

Nope I dont use any ad-blockers but these are they extensions I have: Draw.io Desktop, Google Docs, Google Docs Offline, Google Sheets, Google Slides, Google voice search, My chrome theme, OneNote, Unlimited Free VPN - Hola and Ultrasurf.

I tried disabling all extensions and running the program. I still got the same error message.

Thanks in advance, dude!


#14


#15

Did you check it ... any luck?


#16

@hp07 Oh, I'm sorry! I've had a few tests, and my browser crashed and lost all of my open tabs, so I missed your reply earlier :confused:

Sorry about that.

Can you try placing this code in the bottom of your main function, then running it and telling me what pops up?

$('.arrow-next').click();
$('.arrow-prev').click();

var a = $('.slide:nth-child(1)').hasClass('active-slide');
alert(a);

No luck yet, but I think I may be getting slightly closer to figuring out the problem :slight_smile: