I am using Isotope 2.1.1 and have following code in my wordpress theme's index.php where latest 10 posts are shown using Isotope. I want to have a button to dynamically load older posts and apply Isotope to the loaded content as well. The following code loads the older posts but fails to apply Isotope to the loaded posts. I have also tried using 'container.append( html).isotope( 'appended', html);' as mentioned in the Isotope documentation but no luck.Any help will be much appreciated.
<script>
jQuery(document).ready(function($) {
var container = $('#collage');
function initIsotop(){
container.isotope({
itemSelector: 'article',
resizable: false,
// layout mode options
masonry: {
gutter:0
}
});
}
initIsotop();
//$(window).smartresize(initIsotop());
var count = 2;
var total = <?php echo $wp_query->max_num_pages; ?>;
$("a#more").click(function(){
if (count > total){
return false;
}else{
loadArticle(count);
//initIsotop();
}
count++;
})
function loadArticle(pageNumber){
$.ajax({
url: "<?php bloginfo('wpurl') ?>/wp-admin/admin-ajax.php",
type:'POST',
data: "action=infinite_scroll&page_no="+ pageNumber + '&loop_file=loop',
success: function(html){
//container.append(html).isotope('appended',html);
container.append(html);
initIsotop();
}
});
return false;
}
});
</script>
Aucun commentaire:
Enregistrer un commentaire