jQuery Masonry and Ajax Append Items?

前端 未结 13 1400
借酒劲吻你
借酒劲吻你 2020-12-08 07:19

I am trying to use some ajax and the jQuery Masonry plugin to add some items - but for some reason the new items aren\'t getting the masonry applied ?

I\'m using

13条回答
  •  死守一世寂寞
    2020-12-08 08:02

    You are missing Masonry layout call. According to the docs you need to refresh the layout, executing .masonry() after every change (for instance .masonry('appended')):

    $grid.masonry()
      .append(elem)
      .masonry('appended', elem)
      // layout
      .masonry();
    

    (source: http://masonry.desandro.com/methods.html)

提交回复
热议问题