I'm using jQuery to append an array to a div and I want to display a loading indicator while this process is happening. I added a callback function to my append logic, which works fine. However, the loader disappears before the array is fully rendered in the div.
Is there a way to hide the loader only after the array has finished rendering?
var contentpush = [];
// create x-amount of divs (x being 'tabs')
for (var i = 0; i < tabs; i++){
contentpush.push('<li class="tab" role="tab"><a href="#tab'+(i+1)+'"><span class="icon"><span class="'+contentformat[i].icon+'" ></span></span><span class="title">'+contentformat[i].title+'</span></a></li>');
}
$('.tablist').append(contentpush.join('')).ready(function(){$('#skeleton').hide(); });;
Check out this gif for a visual representation: https://i.sstatic.net/nbqly.gif
As shown in the gif, the loading indicator disappears before the array is fully painted in the div. Any ideas on how to solve this issue would be greatly appreciated!