H
H
habrdima2016-07-19 19:00:32
JavaScript
habrdima, 2016-07-19 19:00:32

mosonry() not working for new photos, how to fix?

I use the mosonry miniframework, when it starts it detects all the photos in the tag and works only with them. If, for example, another photo is added via ajax, then this photo will not be used even if mosonry() is run. I need that by adding photos they were built taking into account the mosonry scheme. Can you suggest another framework?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladislav, 2016-07-19
@habrdima

Masonry has a special method for this:

$('.append-button').on( 'click', function() {
  // create new item elements
  var $items = $('<div class="grid-item">...</div>');
  // append items to grid
  $grid.append( $items )
    // add and lay out newly appended items
    .masonry( 'appended', $items );
});

There is also an isotope. isotope.metafizzy.co

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question