Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to trigger a function when new elements are dynamically loaded?
    primarykey
    data
    text
    <p>I have elements being loaded onto the page via <strong>Script A.</strong> <a href="http://marckremers.com/syndex/js/jquery.infinitescrollfortumblr.js" rel="nofollow">which is old school javascript</a></p> <p><strong><a href="http://marckremers.com/syndex/js/jquery.waypoints.min.js" rel="nofollow">Script B</a></strong> does things to these elements.</p> <p><strong>Script B</strong> works on the elements <em>initially</em> loaded, but when <strong>Script A</strong> loads new elements, <strong>Script B</strong> doesn't know about it.</p> <p>Live, delegate and bind won't work as <strong>Script Bs</strong> function is a custom event.</p> <p>And I'm wondering, surely there is a general fucntion in jQuery which just wakes up and says <em>some ajax just happpend</em>. Then all I'd need to do is repeat <strong>Script Bs</strong> function.</p> <hr> <p>That's the abstract. I dont really want to give more code as I dont think it helps. To give you an idea of what i want to achieve, Script A is a javascript infinite scroll for Tumblr. Script B is fading images in as they enter the viewport. <a href="http://syndex.me" rel="nofollow">It works</a>, but only with the first set of images conventionally loaded.</p> <p>Been stuck on this for four hours and not even close to figuring it out.</p> <p>Thanks</p> <hr> <p><strong>EDIT</strong> Using livequery plugin like so does not work, but it seems tantilising (!) :-/ Maybe it just needs a tweek? </p> <pre><code>$('.theImage').livequery(function() { //.theImage being the dynamically loaded divs $(this).waypoint(function() { //waypoint being Script B which fades in .theImage $(this).animate({opacity: 1}, 'slow'); }); }); </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload