Skip to content

Instantly share code, notes, and snippets.

@Rachind
Created July 15, 2016 06:45
Show Gist options
  • Save Rachind/b0910b65a35b5d7f886643c0ecc76e4d to your computer and use it in GitHub Desktop.
Save Rachind/b0910b65a35b5d7f886643c0ecc76e4d to your computer and use it in GitHub Desktop.
Dynamically Adding HTML Elements to a Masonry Container
var mediaItemContainer = $( '#container' );
mediaItemContainer.masonry( {
columnWidth: '210px',
itemSelector: '.item'
} );
$( mediaItemContainer ).prepend( '<div class="item">foo</div>' );
$( mediaItemContainer ).masonry( 'reloadItems' );
$( mediaItemContainer ).masonry( 'layout' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment