Support » Plugin: AddToAny Share Buttons » AddToAny working with Infinite Scroll Callback

  • Resolved Lui Amisola

    (@lui-amisola)


    Hi Author,

    Good day, I would like to request for an assistance, I have an infinite scroll plugin and it seems like the two are not working together properly, I check the other javascript in my theme that needs callback it works just fine.

    I read other solution in this support thread but it seems that it is not working here is the scripts that i use for the callbacks.

    $(‘body’).trigger(‘post-load’);

    I also tried:
    wpa2a.script_load();
    wpa2a.init();

    do you have other requirements that i need to do for the callback, hope i can get a response from the community thanks!

    https://wordpress.org/plugins/add-to-any/

Viewing 9 replies - 1 through 9 (of 9 total)
  • Plugin Author micropat

    (@micropat)

    Good troubleshooting, Lui. 🙂

    Please point the infinite scroll plugin’s author to this doc. Basically, all infinite scroll plugins should fire the standard post-load event by default after content insertion.

    AddToAny’s initial <script> block is probably getting stripped out by that infinite scroll plugin’s Ajax request parsing. To immediately workaround that, you can add the required JavaScript block to your “Additional JavaScript” box in AddToAny settings:

    if ( 'function' === typeof( jQuery ) ) {
      jQuery( document ).ready( function( $ ) {
          $( 'body' ).on( 'post-load', function() {
              // Init all uninitiated AddToAny instances
              if ( window.wpa2a ) {
                  if ( wpa2a.script_ready ) wpa2a.init();
                  wpa2a.script_load();
              }
          } );
      } );
    }

    Heads up: Keep an eye on AddToAny plugin releases, because soon you won’t need this workaround at all.

    Hi Micropat,

    Good day, I appreciate the quick support, I put the code on the AddtoAny additional javascript box and save it. apparently nothings happening i tried adding a console log in the script but nothings appearing on my console, is there any prerequisites?

    if ( 'function' === typeof( jQuery ) ) {
    console.log('1');
    	jQuery( document ).ready( function( $ ) {
    	  $( 'body' ).on( 'post-load', function() {
    		  if ( window.wpa2a ) {
    			  console.log('2');
    			  if ( wpa2a.script_ready ) wpa2a.init();
    			  wpa2a.script_load();
    			  console.log('3');
    		  }
    	  } );
    	} );
    }

    SALAMAT PO!

    Update:

    Seems like the $( ‘body’ ).on( ‘post-load’, function() is not working, I cannot find any article on google how to make it work.

    But when i removed the post load it is going through, but it is fixing the problem.

    pls help. thank you.

    Plugin Author micropat

    (@micropat)

    Ah! Sorry about that — jQuery probably isn’t loaded yet and please disregard my previous post because I realized that the [currently] required script block also generates the necessary wpa2a.targets to make wpa2a.init() work.

    As mentioned earlier, that infinite scroll plugin you’re using is stripping out inline script blocks so you should report that issue to that plugin’s author. Once fixed, the existing version of AddToAny will work as it does for other infinite scroll plugins & themes.

    Notably, the next AddToAny release doesn’t depend on an inline script block for Ajax, so the infinite scroll plugin’s issue won’t affect AddToAny. The next AddToAny release should be out in less than a week.

    i will be waiting for the next update then… thank you for the awesome plugin and support. keep up the good work!

    Plugin Contributor AddToAny

    (@addtoany)

    @lui-amisola version 1.7 has been released!

    Great! I have updated my plugin to 1.7 is there any additional step that I need to do to make it work? right now, I just updated the plugin and it is not working yet. thank you very much!

    yay! I added the code below and it is now working perfectly, you’re the best!

    jQuery( 'body' ).trigger( 'post-load' );

    @lui-amisola Can you pls help me I am not able to resolve this.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘AddToAny working with Infinite Scroll Callback’ is closed to new replies.