I filter elements on a page and then check how many items are displayed and if there's less than a certain amount I want to load more items using $.get().
I am using the isotope plugin which requires the new items to be a string, but I can only seem to get HTMLDivElement objects. How do I convert this to a string?
var $container = $('#container'),
filters = {};
$container.isotope({
itemSelector: '.element',
});
function loadMoreItems(getQuery) {
var newItems = [];
$.get(getQuery, null, function(data) {
container = $($container, data).eq(0);
if (0 === container.length) {
// incase the element is a root element (body > element),
// try to filter it
container = $(data).filter($container).eq(0);
}
if (container) {
container.find('.element').each(function() {
newItems.push(this);
});
}
alert(newItems); //what to do to get this as a string??
}, 'html');
$container.isotope('insert', newItems, true);
}