I want to lazy-load the results of my Youtube API search, so that as the user scrolls down, Youtube players are being added to the page. It seems that the lazy loading plugins are focused on images, but what I will be loading is just HTML, because I'm using iFrames to load the Youtube players (as per the new Youtube embed style). How can I do this in jQuery? Thanks for reading.
A:
If I understand you correctly you need something like:
$( "body").scroll( function() {
$( "#youtubeDiv").load( "youtube.html");
});
Instead of load you can append html fragment.
Artem Barger
2010-09-26 08:02:01
Shall I guess what's wrong with my answer?
Artem Barger
2010-09-26 14:30:28
A:
You can use the .scroll() and .ScrollTop() functions to detect if you are at the current bottom of the page/scroll. if so, append the next set of iframes to the main element. This also means you need to keep track of the already loaded elements and the available (to be loaded) elements. The latter should be the result of your search.
Milo
2010-10-18 14:05:38
@Artem Barger, I didn't rate you're answer but to answer your question in the comment:You're code would add "youtube.html" anytime "scroll" is called which would be a _lot_ of times.
Milo
2010-10-25 07:58:50