Masonry items not reloaded when cliking ajax load more button

给你一囗甜甜゛ 提交于 2019-12-03 08:56:50

I think that you can use $container.masonry(); after adding your elements, like this :

$("div.posts-holder").append(html).each(function(){
    $('.posts-holder').masonry('reloadItems');
});

$container.masonry();

You can see it working here.

Hope that can help.

you have to use the appended method of masonry ... otherwise how would it know that you have added any new element.

Adding the elements simply wont align them as masonry doesnt have any event listner for new element added.

  var el = $('<div class="kesif-gonderi-alani" style="height:300px;"></div>') 
  $container.masonry().append( el ).masonry( 'appended',el );  

Hers is small demo on codepen http://codepen.io/knaman2609/pen/xbJMRY

Click on the button to append elements dynamically

http://masonry.desandro.com/methods.html

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!