• I currently have the latest (2.12.0) version of this plugin. I am currently testing these callback functions (almDone and almEmpty) on a Chrome browser and the desired console messages does not log for both when conditions are true. In a separate JS file, I have the following code.

    (function ($) {
    	//1. almDone
        $.fn.almDone = function(alm){
           console.log('All posts have been loaded!');
        };
        	//2. almEmpty
        $.fn.almEmpty = function(alm){
           console.log('Sorry, but we could not locate any posts that matched your criteria.');
        };
    })(jQuery);

    I also made sure that the file is loaded after the Ajax Load More plugin JS file. Here is a snippet code from my functions.php file.

    add_action( 'wp_enqueue_scripts', 'site_assets');
    function site_assets() {
     ...
     wp_register_script( 'ajax-load-more', plugins_url() . '/ajax-load-more/core/js/ajax load-more.min.js', array( 'jquery' ), '2.12.0', true );
     ...
     wp_register_script( 'ajax-load-more-callback', get_template_directory_uri() . '/js/ajax-load-more-callback.js', array( 'jquery', 'ajax-load-more' ), null, true );
     ...
     if ( ( is_home() || is_post_type_archive ( array( 'web_design', 'other_works' ) ) ) || is_tag() ) {
     ...
     wp_enqueue_script( 'ajax-load-more-callback' );
    }
    • This topic was modified 9 years, 8 months ago by migs7792. Reason: added more sample code for clarification of the problem
    • This topic was modified 9 years, 8 months ago by migs7792.
    • This topic was modified 9 years, 8 months ago by migs7792.
Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author Darren Cooney

    (@dcooney)

    Hi @migs7792,

    I am currently testing these callback functions (almDone and almEmpty) on a Chrome browser and the desired console messages does not log for both when conditions are true.

    Are you saying they will fire though, just not at the same time?

    Also, why are you enqueue’ing the Ajax Load More css? That will be enqueued by the plugin.
    Cheers,

    Thread Starter migs7792

    (@migs7792)

    No, each callback function won’t fire when the necessary conditions are present. almEmpty() (for example) won’t even log the console message in the browser when query returns no post.

    Also, I only registered the Ajax Load More js file, not the css, so I can give it a handle name to be used as dependency for the ‘ajax-load-more-callback.js’.

    I hope this clarifies things up.

    Plugin Author Darren Cooney

    (@dcooney)

    @migs7792 – Can you share a link to the page with your issue please?

    Cheers,

    Thread Starter migs7792

    (@migs7792)

    Hello! It has been more than a week! I just uploaded my website from localhost to live. Here is the page.

    http://migsmarbella.com/web-design/

    No console log message appears when conditions for $.fn.almEmpty() are true. I recently tested $.fn.almDone() and it’s working. Here is an example image.

    console-log-img

    Additional info: I am using the ‘Preloaded Posts’ feature of the plugin as well. The archive page does not generate console message when there are no posts to preload. I hope you understand.

    • This reply was modified 9 years, 7 months ago by migs7792. Reason: Image does not seem to load in msg. Replaced with a link instead
    Plugin Author Darren Cooney

    (@dcooney)

    @migs7792 – That makes sense then…
    if you are using Preloaded and not enough posts are returned in the Preloaded query to require an Ajax call the callbacks with not fire.

    Basically, Callbacks only fire after an Ajax request.

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

The topic ‘Callback functions NOT firing?’ is closed to new replies.