diff --git a/js/auto-reload.js b/js/auto-reload.js index d015dfc1..0a38f9b2 100644 --- a/js/auto-reload.js +++ b/js/auto-reload.js @@ -144,19 +144,26 @@ $(document).ready(function(){ url: document.location, success: function(data) { var loaded_posts = 0; // the number of new posts loaded in this update + var elementsToAppend = []; + var elementsToTriggerNewpostEvent = []; $(data).find('div.post.reply').each(function() { var id = $(this).attr('id'); if($('#' + id).length == 0) { if (!new_posts) { first_new_post = this; } - $(this).insertAfter($('div.post:last').next()).after('
'); new_posts++; loaded_posts++; - $(document).trigger('new_post', this); - recheck_activated(); + elementsToAppend.push($(this)); + elementsToAppend.push($('
')); + elementsToTriggerNewpostEvent.push(this); } }); + $('div.post:last').next().after(elementsToAppend); + recheck_activated(); + elementsToTriggerNewpostEvent.forEach(function(ele){ + $(document).trigger('new_post', ele); + }); time_loaded = Date.now(); // interop with watch.js