• Hi

    First of all, thanks for your great plugin.

    Second of all, I have a question: I’m loading posts via Ajax (filtered by tags), and the ALM button doesn’t appear after the Ajax insertion.
    I tried triggering the post-load event, but that doesn’t seem to help.

    What’s the correct way to get the infinite scroll to work after Ajax insertion?

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

    (@dcooney)

    @leac sorry, im just not sure what you mean… Ajax Load More loads the posts with ajax, are you loading ajax load more via Ajax?

    What is the post-load event your are referring too?

    Thread Starter Lea

    (@leac)

    Hi

    I have a list of tags on the sidebar. When the user enters the page, all posts appear (without tag filtering), and the ALM button appears at the end of the list, loading more posts as the page scrolls.
    When the user clicks a tag on the sidebar, the posts belonging to that tag are loaded via Ajax (without refresh). When that happens, we want the ALM button to appear again, but it doesn’t.

    The event I’m referring to is:
    jQuery( document.body ).trigger( 'post-load' );
    as described in the Codex.

    Plugin Author Darren Cooney

    (@dcooney)

    Oh, I’d never heard of the Post Load event before. You could call that using the almComplete callback function if you require.

    Alternatively, you could built your own tag filter system using Ajax Load More filtering.
    https://connekthq.com/plugins/ajax-load-more/examples/filtering/

    Thread Starter Lea

    (@leac)

    Thanks, but I’ve already built the tag filtering system.

    What I need to know is how to invoke the ALM by JavaScript. I hope I can explain it well enough…

    In my AJAX callback (in PHP) I call AL like this:

    $infinite_scroll_shortcode = '[ajax_load_more post_type="post" category="teaching-resources" tag="' . get_query_var( 'tag' ) . '" post__not_in="' . implode( ',', $posts_loaded ) . '"]';
    		echo do_shortcode( $infinite_scroll_shortcode );

    I followed the PHP and saw that the class (ALM_SHORTCODE) is run. But the ALM Javascript isn’t run.

    Is my explanation clear enough? Could you to explain to me how to make it work?

    Plugin Author Darren Cooney

    (@dcooney)

    Yea, i see what you want to do.
    I’ve never tried this, i wonder if the Ajax Load More JS is present on the page.

    You could try calling almTriggerClick() function after your ajax call.
    https://connekthq.com/plugins/ajax-load-more/docs/public-functions/#almTriggerClick

    Moderator Jan Dembowski

    (@jdembowski)

    Forum Moderator and Brute Squad

    @dcooney These forums now support oEmbed from WordPress posts. If you need to share a link with an ID tag, make that a link explicitly like this.

    https://connekthq.com/plugins/ajax-load-more/docs/public-functions/#almTriggerClick

    Which ought to work and not trigger the embedding.

    Thread Starter Lea

    (@leac)

    Hi @dcooney

    Thanks, but that still doesn’t place the button on the page, nor does it load the rest of the posts…

    Would a link to the page on my site help? Although my site is in Hebrew, I could explain to you what to do in order to reach the situation I’m facing.

Viewing 7 replies - 1 through 7 (of 7 total)
  • The topic ‘How to trigger ALM after loading posts with AJAX’ is closed to new replies.