After ajax added new containers it killed methods initialized for them, what can I do to make django-endless-pagination add some JQuery to its generated containers? For example i have:
$(".fact").each(function() {
$(this).css('border-top', '5px solid ' + colors[Math.floor(Math.random() * colors.length)]);
});
and i want to add this to each .fact generated after ajax call.
Take a look at the Attaching callbacks section from the documentation :)
Supposing this is your endless pagination initialisation you can add some code to be executed on each new reload.
<script>
$.endlessPaginate({
paginateOnScroll: true,
paginateOnScrollMargin: 100,
paginateOnScrollChunkSize: 5,
// add your code in onCompleted
onCompleted: function(context, fragment) {
$(".fact").each(function() {
$(this).css('border-top', '5px solid ' + colors[Math.floor(Math.random() * colors.length)]);
});
});
}
});
</script>