1

I have a list of states that displays or hides on click of a button using jquery slideUp() and sideDown() functions.

I'm trying to use jquery tinyscrollbar to add a custom scrollbar to it.

I have a jsfiddle here: http://jsfiddle.net/ByteMyPixel/acLch/

I almost have it working, but am stuck - the tinyscrollbar shows on the second click event/slideUp() instead of slideDown().

Any ideas on how to fix this so that the tinyscrollbar appears on slideDown(), and disappears on slideUp()?

Here is my code:

var oScrollbar1 = $('#scrollbar1');
oScrollbar1.tinyscrollbar();

$("a.button").click(function () {

oScrollbar1.tinyscrollbar_update();

    if ($("ul.scrolling").is(":hidden")) {
        $("ul.scrolling").slideDown("slow");
    } else {
        $("ul.scrolling").slideUp("slow");
    }
});
ByteMyPixel
  • 151
  • 2
  • 3
  • 15

2 Answers2

4

Using the tinyscrollbar for jQuery like this:

var scroll = $("#add-widget-scroll").tinyscrollbar();

I did some research and I found that the "update" function can be accessed using this:

$(scroll).data().plugin_tinyscrollbar.update();
avcajaraville
  • 9,041
  • 2
  • 28
  • 37
Hagau Ioan
  • 51
  • 2
3
    var oScrollbar1 = $('#scrollbar1');
    oScrollbar1.tinyscrollbar();

    $("a.button").click(function() 
    {
        $("ul.scrolling").slideToggle("slow", function()
        {                               
            oScrollbar1.tinyscrollbar_update();
        });
    });

This will fix your problem :)

PhearOfRayne
  • 4,990
  • 3
  • 31
  • 44
Baijs
  • 1,847
  • 3
  • 20
  • 35
  • Not sure why of the rollback after my edit no reason given by @Steven. The method 'tinyscrollbar_update' works on version 1.81 and version 2.0.3 of tinyscrollbar contains another method to update just called 'update'. – Robert Brisita Mar 11 '14 at 20:27