I have div.scrollContainer
where I insert a bunch of items. When the page loads, I run mCustomScrollbar jQuery plugin which will take the items inside div.scrollContainer
and wrap its own classes/css/js around it to create the custom scroll bar.
When the page loads, I go through my own library which outputs some more items for me to inject into the scroll bar. I am currently targeting/appending them to the custom classes mCustomScrollbar creates. The problem, however, is that sometimes my library outputs the items before mCustomScrollbar has created its classes. As a result, the items from the library can never be placed inside the correct element because it doesn't exist.
I have thought about appending the items from the library to div.scrollContainer
, but then I run into the issue of what if mCustomScrollbar has created its classes before the items are appended.
All in all, I am wondering if there is a way to detect when a new element is created in the DOM. I have looked into this other thread where it was suggested to use the livequery plugin. I'm wondering if there is a solution that does not require an additional plugin.