html - jQuery reinitiate css :after on div after jquery function terminated -


i creating justified gallery using code here: http://jsfiddle.net/thirtydot/edp8r/3/

i use infinitescroll load more items.

current js:

$("#posts").infinitescroll({ navselector  : '#page_nav',    // selector paged navigation  nextselector : '#page_nav a',  // selector next link (to page 2) itemselector : '.item',     // selector items you'll retrieve loading: {     finishedmsg: 'no more pages load.',     img: 'http://i.imgur.com/qkky8.gif'   } },  function( newelements ) {             $( newelements ).each(function() {                 $(this).css("width", $(this).width());             });              $('#posts').removeclass('posts').addclass('posts'); } );       

css:

#posts.posts{     text-align: justify;     -ms-text-justify: distribute-all-lines;     text-justify: distribute-all-lines; }  #posts.posts .post{     height: 250px;     vertical-align: top;     display: inline-block;     *display: inline;     zoom: 1 }  #posts.posts:after {     content: '';     width: 100%;     display: inline-block;     font-size: 0;     line-height: 0 } 

this code works fist chunk of loaded items, ignores items loaded infinite scroll

already tried (found answer in similar post):

$("head").append($('<style>div#posts:after { content: "";width:100%;display:inline-block;font-size:0;line-height:0; }</style>')); 

i found answer each new element should have space added added $(this).before("&nbsp;");

new is:

$("#posts").infinitescroll({ navselector  : '#page_nav',    // selector paged navigation  nextselector : '#page_nav a',  // selector next link (to page 2) itemselector : '.item',     // selector items you'll retrieve loading: {     finishedmsg: 'no more pages load.',     img: 'http://i.imgur.com/qkky8.gif'   } },  function( newelements ) {             $( newelements ).each(function() {                 $(this).before("&nbsp;");                 $(this).css("width", $(this).width());             });              $('#posts').removeclass('posts').addclass('posts'); } );  

Popular posts from this blog

How to calculate SNR of signals in MATLAB? -

c# - Attempting to upload to FTP: System.Net.WebException: System error -

ios - UISlider customization: how to properly add shadow to custom knob image -