• Resolved etaymor

    (@etaymor)


    Hey,

    Trying to setup my load more callback so I can reinitialize Masonry, but it doesn’t look like the callback is firing. I’m just trying a simple console.log and nothing is getting printed. My app.js file is loaded after the AJAX Load More jquery. Posts are being loaded into the Dom so the plugin is working correctly. I’m using the version that fires on click (as opposed to scrolling)

    Has anyone come across this?

    $.fn.almComplete = function(alm){
        console.log("callback posts") // Not being called
          $container.imagesLoaded( function() { // When images are loaded, fire masonry again.
            $container.masonry('reloadItems');
            console.log("reload masonry") // Not being called
          });
      }

    https://ww.wp.xz.cn/plugins/ajax-load-more/

Viewing 13 replies - 1 through 13 (of 13 total)
  • Plugin Author Darren Cooney

    (@dcooney)

    Is your $.fn.almComplete function in a document.ready and is your site JS loaded after ALM?

    Cheers,

    Thread Starter etaymor

    (@etaymor)

    Hey dcooney-

    Yup! I initially hadn’t done this, but realized I needed to and moved it down. My app.js file where this resides is the last thing on my page.

    Despite it being the last thing that callback function isn’t being hit, which I can’t figure out for the life of me.

    Plugin Author Darren Cooney

    (@dcooney)

    Is it possible to share a link?

    Thread Starter etaymor

    (@etaymor)

    Hey Dcooney (and anyone else)-

    You can see the staging site here: http://tvrev.actsofphilosophie.com/

    The load more button is somewhat hidden now, but you can pull it up using the Inspector and just assign the z-index to 9999 and move top to like 2000px or 1500px

    I have it so it just fires on a click event and just does one post for easy testing. I’ve shrunk my JS for that portion to:

    $.fn.almComplete = function(alm){
        console.log("callback posts")
      }
    Plugin Author Darren Cooney

    (@dcooney)

    I can’t get the button to show… Can you fix this?

    Thread Starter etaymor

    (@etaymor)

    Hey!

    Just made the button show up. Let me know if this helps and thanks in advance for your help.

    Plugin Author Darren Cooney

    (@dcooney)

    Ok thanks. I’m not sure why this isn’t firing.

    All I can think of is there might be something up with your repeater template but im really not sure.

    Thread Starter etaymor

    (@etaymor)

    Gah! Very strange. The weird thing is the posts are loading when clicked. So it’s working just the JS isn’t firing. Any other plugins accomplish something similar (Load more posts on click)? I’ll try to take a look under the hood tomorrow too.

    Plugin Author Darren Cooney

    (@dcooney)

    Im not sure. if there is another plugin it definitely isn’t as good as mine πŸ™‚

    I just tested the callback on 4 different installs and it’s working on all.

    Thread Starter etaymor

    (@etaymor)

    I believe you! Just to confirm, you are doing it on click events IE:

    <?php echo do_shortcode( '[ajax_load_more post_type="post" offset="10" pause="true" scroll="false" posts_per_page="1" button_label="More Posts"]' ); ?>

    Any special settings? I’m using: more-posts-container

    Container type: Div
    Custom container class
    Dynamic Content: False
    AJAX Security: False
    Top of page: True
    Disable CSS: True

    Plugin Author Darren Cooney

    (@dcooney)

    No, not on click.
    It’s triggered after the data has been returned from the ajax call.

    Thread Starter etaymor

    (@etaymor)

    I get that, but in the plugin there is one option to have the posts loaded on scroll and another on click.

    I’m noticing some pretty weird stuff with my asset loading that may be contributing to this, I have a hunch that is the issue. Thanks for your help! I will keep you posted and let me know if anything comes ot mind

    Andrew Jacobs

    (@flyingtrolleycars)

    I’m seeing this same behavior and noticed that I’m assigning a function to $.fn.almComplete but the big caveat is that when you get to line 795 window.jQuery === $ is false. It’s looking at a different jQuery object… This might have to do with a no-conflict mode, or maybe the jQuery-migrate script…

    Line 795 being:

    // ALM Complete
                if ($.isFunction($.fn.almComplete)) {
    	            if(alm.images_loaded === 'true'){
    	               alm.el.almWaitForImages().done(function(){
    							$.fn.almComplete(alm);
    						});
    					}else{
    						$.fn.almComplete(alm);
    					}
                }

Viewing 13 replies - 1 through 13 (of 13 total)

The topic ‘Load More Callback not working’ is closed to new replies.