Fairly simple concept. I have a paginated datasource which feeds content to a masonry wall in blocks of 15. I want to stick a 'Load More' button on there.
Do I need to load the whole DS and eliminate pagination, then just mask it with jQ? Sounds like it could get laggy?
How can I wire up this functionality? To only feed in the XML output if it's requested? I tried briefly to take an existing Append button from the masonry docs but my code made it work as a link to page "NaN" ... I've not really mixed XSL and jQuery too much. Don't know where to start.. Below is my code for the button.
<a href="{$root}/?page={/homepage-aritcles/pagination/@current-page + 1}"> <button id="append-button">++++ LOAD MORE POSTS ++++</button> </a>
Here's the relative js:
function getItemElement() {
var elem = document.createElement('div');
elem.className = 'item ' ;
return elem;
}
$(function(){
var $container = $('.post.content'),
$boxes = $container.find('.item'),
firstTime = true;
$(window).smartresize(function(){
var containerWidth = $container.width(),
colWidth = Math.floor( containerWidth / 3 ),
applyStyleFnName = firstTime ? 'css' : 'animate';
$boxes.each(function(){
var $this = $(this),
cols = $this.data('cols'),
boxWidth = Math.floor( colWidth * cols );
$this[ 'css' ]({ width: boxWidth }, { queue: false });
});
$('#append-button').on( 'click', function() {
var elems = [ getItemElement() ];
$container.append( elems ).masonry( 'appended', elems );
});