How to use Jquery Custom Scrollbar on elements with display:None

Asked

Viewed 167 times

2

It does not mount the scroll bar on elements that are "display: None". Does anyone know how to solve?

Here the scrollbar plugin

  • 1

    Do you happen to have any example of code to show us that it would be easier to help?

  • It will take an example to understand this question, in theory if an element has display: none DOM does not calculate dimensions and composition of this element, without which it is not possible to add a scroll to it.

2 answers

1

Put an Handler to your elements for when they are displayed:

$('.elemento').each(function() {
    if (!$(this).is(':visible')) {
        return;
    }
    $(this).mCustomScrollbar({
        scrollButtons: {
            enable: true
        }
    });
});

0

The element can only be used by jQuery when the element is comi display:block or something similar, you could try applying the custom scrollbar as soon as the element is displayed.

Ask the question like this: What action did you take to get custom scrollbar applied? " is in the event some element click that is being displayed", then call custom scrollbar assembly in the event.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.