0

I have a toggle button that show a side menu.

The side menu have a niceScroll.

I try hide niceScroll on hide menu event and that's working and I can see the cursor(niceScroll bar). Now on show menu event I try to show niceScroll and It's working but the cursor still hide.

I'm using this code for hide niceScroll at "hide menu event":

$("#sidebar").getNiceScroll().hide()

And this code to show niceScroll at "show menu event":

$("#sidebar").getNiceScroll().show()

any help please

Update

when I try to show it by clicking on menu, the css is:

left:-6px

I think it's a bug, didn't it ?

here is my code

mustint
  • 49
  • 1
  • 11
  • did you try move the hide/show to where sidebar collapse "shown" or "hide" functions is instead? – zerohero Jan 30 '17 at 09:12
  • There is no event for sidebar collapse. in my code the collapse events not for sidebar toggle. these events for sidebar items (items that have a childs) – mustint Jan 30 '17 at 09:26
  • yes there is... $('.sidebar .collapse').on('shown.bs.collapse', function () { <-- that's the code that checks if the sidebar has collapsed or the other one, hidden; – zerohero Jan 30 '17 at 11:31
  • @zerohero . this code for side bar items. please refer to my example above and see menu items. you'll notice "Products". the collapse code for like this items – mustint Jan 30 '17 at 12:52

1 Answers1

1

here is my solution based on this issue solution

I used remove instead of hide like this:

$("#sidebar").getNiceScroll().remove();

and I move the niceScroll initial from document.ready to a function callNiceScroll() and at the menu show event I call it with timeout:

setTimeout(callNiceScroll, 400);

and now it's working

mustint
  • 49
  • 1
  • 11
  • 1
    That's exactly what I suggested, to move the call to nice scroll to the menu show or hide event; $('.sidebar .collapse').on('shown.bs.collapse', function () { – zerohero Jan 30 '17 at 11:32
  • @zerohero . you should be more clear. however you give me the idea. thanks – mustint Jan 30 '17 at 13:26