I need to know when all images are loaded from an added HTML source to perform another function. How can I check this?
$(document).ready(function () {
$('a.load-more').click(function (e) {
e.preventDefault();
$.ajax({
type: "GET",
url: $(this).attr('href'),
data: {
page: last_id
},
dataType: "script",
success: function () {
$('.load-more').show();
}
});
});
});
I add the html source as follows:
$('.container').append('<%= escape_javascript(render(:partial => @items)) %>');
It gives the html source successfully, but I cannot find out when all the images from this source are loaded
.container is updated every time you click a link <a href="/items" class="load-more">Load more</a>
and the source .container looks like this:
<ul class="container">
<%= render @items %>
</ul>
source
share