Tuesday, 20 August 2013

How does "newElements" work in Javascript?

How does "newElements" work in Javascript?

$container.infinitescroll({
navSelector : "div.navigation",
nextSelector : "div.next-page a:first",
itemSelector : "#posts-container div.post",
bufferPx : 80
},
function( newElements ) {
var $newElems = $ ( newElements );
$container.masonry( 'appended', $newElems );
}
);
While implementing infiniteScroll plugin, I used newElements without
actually knowing what it really is. In the presented code, I passed
newElements in as a parameter but it wasn't declared anywhere above.
However, the function works fine; new posts elements are stored in
$newElems.
When I use newElements, am I conveniently calling all the newly added
elements to the DOM?

No comments:

Post a Comment