I'm working with Tumblr documentation to make it so when the page theme loads a certain post (ask posts in this case), it appends the html of that post into a separate fixed div that acts like a "chatLog" or sorts that continuously loads those posts as new messages as they show up (because infinite scrolling that continuously loads new posts is being considered here instead of pagination). Since I have infinite scrolling enabled, I can't simply use page onload or .each here, and can't figure out what to use other than $('.ask').ready()
Right now, what I have is
$(".ask").each(function() {
var self = $(this);
$(self).ready(
function(){
$("#chatLog").append($(self).html());
});
});
but this clones instances (when I have four asks posts on the page, the first one appears 4 times, the second 3 times, the third 2 times, the fourth one time), and I'm not sure how wonkier the result will be once I enable the infinite-scrolling
and if I take out the .each, I can't reference the div objective with $(this) using just .ready()
*Note: Tumblr documentation doesn't let me simply load all the ask posts into the fixed div from the start because you can't separate ask posts from the general "posts block" consisting of all the other posts (text, photo, photoset, audio, video, etc.) too
.ready()you're talking about is generic jQuery, then regular DOM elements do not have.ready()capability. if you're trying to handle events from dynamically loaded elements, then you will want to use delegated event handling as described here Does jQuery.on() work for elements that are added after the event handler is created?. This allows you to attach an event handler to a common parent element and use event bubbling from dynamic elements. - jfriend00.ready()? When element exists indocument, call.each()on element ? - guest271314