views:

50

answers:

1

Hey, sorry to be such a nuisance, but I have another jQuery problem. Same code.

$('.tab').click(function() {
        $(this).unbind("click");

        var classy = $(this).attr("class").split(" ").splice(-1);
        var ihtml = $('.content.'+classy).text();
        $('#holder').html(ihtml).slideDown("slow");

        $('.tab:not(.active)').live('click', function () { 
                $('.tab').removeClass('active');
                $(this).addClass('active');
        });

});

Basically, the problem is, when I click on the tabs, the html content will update, but after I've pressed it once, it won't update, and the content remains the same as the previous tab. Any ideas?

+2  A: 

The code you have removes the click handler event from the clicked tab. So it will fire the first time it is clicked but not any other times.

Remove this line:

$(this).unbind("click");
Lance McNearney
i need to unbind the click thing for the current tab though, because if i don't, double clicking causes the content to disappear. Any ideas?
Johnny
You could check if the clicked tab is already "active" or not and then just ignore the click. Something like: if($(this).is(".active")) { return; }
Lance McNearney