views:

39

answers:

3

hello - i've made an image slide show which works with either a next button, or if you click on the right or left of the screen it shows the next slide.

problem is when i click the next button the click bind also fires which means it move forward 2 slides.

How can i get the click bind to ignore the click if th next button is clicked?!

    $(opts.next).click(function(){

        nextSlide();

    });

    function nextSlide() {
        $slides.eq(currentSlide).fadeOut(opts.speed)

        currentSlide++;

        (currentSlide==totalSlides ? currentSlide=0 : false);

        updateSlideSHow()

    }

    function previousSlide() {
        $slides.eq(currentSlide).fadeOut(opts.speed)

        currentSlide--;

        (currentSlide<0 ? currentSlide=(totalSlides-1) : false);

        updateSlideSHow()

    }

    $(this).bind('mouseup',function(e){
        var ww = $(window).width();

        (e.pageX < (ww/2) ? previousSlide() : nextSlide());
            //alert(e.pageX+"<"+ww);

    });

any help appreciated!

A: 

Where are the "next" buttons according to the DOM? Is the screen element, where I can click and go to the next slide, the parent element of these buttons?

The reason I ask is if they are that way, for instance:

<div id='screen'>
<img id='nextBtn' />
</div>

I'm not 100% but I would think if you tried clicking on the image button that the div would also register as a click, since its the parent element. Instead you could try this:

<div id='screen'></div>
<img id='nextBtn' />

And position the screen element absolutely and behind the image element.

TJ Kirchner
yeh - maybe $(document) could of been $('something else') – cheers
daniel Crabbe
A: 

ok - basically got the click to check for a URL before executing;

            $(document).bind('click',function(e){
                var ww = $(window).width();

                if(!$(this).attr('href')) $()(e.pageX < (ww/2) ? previousSlide() : nextSlide());
                //alert(e.pageX+"<"+ww);

            });
daniel Crabbe
A: 

Just curious, but if clicking the button would go to next through the click event, why not leave a button that does nothing there?

Lunin