0

I have rotating jQuery tabs which I want to pause when you hover over them and stop rotating when you click.

However, although the pausing works fine, I cannot unbind the hover event (even unbinding mouseenter and mouseleave separately).

I've created two jsfiddles here with two different approaches, both of which have the same problem.

http://jsfiddle.net/bdrvC/15/

function tab_hover_in() {
        $(this).tabs('rotate', 0, false);
}
function tab_hover_out() {
        $(this).tabs('rotate', 3000, false);
}
function tab_click() {
        $(this).tabs('rotate', 0, false);
        $(this).unbind('mouseenter',tab_hover_in);
        $(this).unbind('mouseleave',tab_hover_out);
        event.preventDefault();  
}

$('.tabs-rotate').tabs({
        selected: 'tabs-1'
}).tabs('rotate', 3000, false);

$('.tabs-rotate').bind({
        'click': tab_click,
        'mouseenter': tab_hover_in,
        'mouseleave': tab_hover_out
});

http://jsfiddle.net/bdrvC/16/

$('.tabs-rotate').tabs({
  selected: 'tabs-1'
}).tabs('rotate', 3000, false);

$('.tabs-rotate').hover(function() {
    $(this).tabs('rotate', 0, false);
  }, function() {
    $(this).tabs('rotate', 3000, false);
});
$('.tabs-rotate').click(function() {

  $(this).tabs('rotate', 0, false);
  $(this).unbind('mouseleave');

});

Could anyone explain why the rotation continues even after the click?

Many thanks!

1 Answer 1

1

your click event isn't getting bound to the proper element...you could use

$('.ui-tabs-nav li a').click(function() {...});

instead

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.