4

I'm using perfect-scrollbar with some dynamically generated elements

I used "DOMNodeInserted" event to do that

$(document).bind('DOMNodeInserted', function (event) {
        $('.scrollable,.k-grid-content,.portlet-body').perfectScrollbar();
    });

but I got this error

perfect-scrollbar.jquery.min.js:2 Uncaught RangeError: Maximum call stack size exceeded.

How can I fix this error?

Is there another way to get perfect-scrollbar to work on dynamically generated elements?

thank you

FDI
  • 771
  • 1
  • 9
  • 25
  • 1
    You would have better to just recall plugin initialization once element is appended to the DOM instead of using `DOMNodeInserted` event which will be fired by plugin itself, because precisely, this plugin is adding new elements to the DOM to handle custom scroll bar. See [XY problem](http://meta.stackexchange.com/questions/66377/what-is-the-xy-problem) – A. Wolff Aug 20 '16 at 15:30
  • 1
    Thank you, you comment helped me to solve the problem – FDI Aug 21 '16 at 14:58
  • hi, me also have problem with dynamically generated elements inside perfectScrollbar plugin. Could you post solution here? – johannesMatevosyan Jan 17 '17 at 12:04

0 Answers0