Timur
Timur

Reputation: 43

Simple tabs with content scroll

I use universal jqueryUI tabs with jQuery custom content scroller and it only works on the first tab, pls help me fix this code - jsFiddle This Code

 (function($) {
   $(function() {
     $('ul.tabs').delegate('li:not(.current)', 'click', function() {
       $(this).addClass('current').siblings().removeClass('current')
         .parents('div.section').eq(0).find('>div.box').hide().eq($(this).index()).show();
     })

   })
  })(jQuery);   
  (function($){
    $(window).load(function(){
           $('.scroller').mCustomScrollbar({
        autoHideScrollbar:true
                });
            });
   })(jQuery);

Thanks.

Upvotes: 2

Views: 218

Answers (1)

Zach Saucier
Zach Saucier

Reputation: 25974

It's because you're only adding a scroller on $(window).load. You need to make add functionality to compensate for changing tabs as well, like this:

(function($){
    $('.tabs').click(function() {
        $('.scroller').mCustomScrollbar("destroy");
        $('.scroller').mCustomScrollbar({
            autoHideScrollbar:true
        });
    });
})(jQuery);

Updated jsFiddle

Upvotes: 1

Related Questions