mixitup icon indicating copy to clipboard operation
mixitup copied to clipboard

Dataset API with Load More button - how to append

Open jeffceriello opened this issue 4 years ago • 0 comments

Hi there,

I have a website with a list of News items being displayed via the dataset API. The list is set to show 7 news items on page load.

function load_items(term) {
	$.getJSON( '/wp-json/wp/v2/posts?orderby=menu_order&order=asc' + term)
		.done(function(data) {
			mixer.dataset(data);
		})
		.fail(function(data) {
			console.log( "error" );
		});
}

I'm trying to append 6 more every time a Load More button is clicked but I can't figure out how to update the dataset and append the extra news items without having to reload the entire list.

$loadMore.on('click', function() {
	pagelimit = pagelimit + 6;
	load_items('&per_page=' + pagelimit);
});

This is what the button click function looks like. On click I request another load_items() that will return a list of 7+6 news items, then the list will re-render completely. How can I append only the new news items without re-rendering the entire list?

Thanks

jeffceriello avatar Mar 13 '20 14:03 jeffceriello