阿积士和石工

Hi guys I have a little issue here I want to use this code for load more

$(document).ready(function(){
var page = 1;
    var pages = $("#pages").val();

    $("#content").load("resources/more.php");
    $("#loadmore").bind("click", function(){
        var next = page+=1;

        $.get("resources/more.php?page="+next, function(data){
            var el = jQuery(data);
            if(next==pages){

                $("#loadmore").remove();
            }
            $("#content").append(el).masonry( 'appended', el, true );
                    //$("#content").append(el).masonry( 'reload' );
        });
    });
    });

Load more is working quite fine nevertheless Masonry isn't working at all. Thanks for help.

The issue is due to a bug I helped find! It turns out that $.get() returns the HTML with some underlying DOM structure that Masonry doesn't like.

To fix it, change this:

var el = jQuery(data);

To this:

var el = jQuery(data).filter('div');

You can read more about it here: https://github.com/desandro/masonry/issues/374