Reputation: 3323
I have a page where I'm trying to apply the tinyscrollbar plugin to some div loaded through AJAX. The plugin breaks and I get the oViewport.obj[0] is undefined
error in the console.
The same code works on other divs that already exists on the page. Any ideas? Thanks
The CODE is:
$("#sidebar-right").html("<div>bla bla bla <div class='tinyscroll'>bla bla bla</div> bla bla bla</div>");
$(".tinyscroll").tinyscrollbar({sizethumb: 24, wheel: 10});
Upvotes: 1
Views: 1877
Reputation: 3323
The problem was that I was adding all the html markup ( needed by tinyscroll ) to the div I wanted through jquery (using $(selector).wrap(some elements)
). I tested to see if the new alements exists in the DOM and they were present, but tinyscroll couldn't find them. Now I added that html markup to the ajax response itself and it's working.
But I still can't figure it out why it works on other divs not loaded via ajax.
Upvotes: 1