Last active
August 29, 2015 13:56
-
-
Save zmajstor/9174680 to your computer and use it in GitHub Desktop.
how to wait for jQuery .append to finsh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="card"> | |
<%= image_tag (collection.designer.cover_image_url), class: "center-block" %> | |
<div class="card-hover"> | |
<span class="card-overlay"> | |
<%= collection.designer.fullname %><br> | |
<%= collection.designer.live_collection.name %><br> | |
<%= collection.designer.location %> | |
</span> | |
</div> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
<div class="container card-container text-center" id="masonry-card-container"> | |
<%= render @collections %> | |
</div> | |
... |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var $masonryContainer = $('#masonry-card-container'); | |
var $newItems = $('<%= escape_javascript render(@collections) %>'); | |
$masonryContainer.append($newItems.hide()); | |
$masonryContainer.waitForImages(function() { | |
// All descendant images have been loaded | |
setTimeout(function(){ | |
// Action after append | |
$newItems.show(); | |
$masonryContainer.isotope( 'appended', $newItems ); | |
}, 50); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var $container = $('#masonry-card-container'); | |
$( window ).load(function() { | |
$container.isotope({ | |
itemSelector: '.card', | |
layoutMode: 'masonry', | |
masonry: { gutter: 5 } | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment