I have a feed section on my website which renders user posts. I have a custom.scss stylesheet which holds all my styling that is loaded when I load my application.
The problem is I have a javascript which fetches more posts upon reaching the bottom of the page. When the script gets more posts the styling doesn't style the posts correctly, on the first retrieval or the second, third etc lot of posts.
I read the asset pipline doc thinking that would give me a answer but didnt here.
I was wondering if anyone knew why my app is doing this, hopefully just something I can include in my script js file or something?
Upon sergio's suggestion my js code.
views/static_pages/home.js.erb
$('#feed').append('<%= escape_javascript render(@feed_items) %>');
$('.pagination').replaceWith('<%= escape_javascript will_paginate(@feed_items) %>');
app/assets/javascripts/endless_scroll.js
$(document).ready(function() {
if ($('.pagination').length) {
$('.dynamicdisplaypanel').scroll(function() {
var url = $('.pagination .next_page').attr('href');
if (url && $('.dynamicdisplaypanel').scrollTop () >= $('.dynamicdisplaypanel')[0].scrollHeight - $('.dynamicdisplaypanel').height ()) {
$('.pagination').text("Please Wait...");
return $.getScript(url);
}
});
return $('.dynamicdisplaypanel').scroll();
}
});