jqueryajaxstumbleupon

Ajax loaded StumbleUpon badge not working


I am adding social media buttons in an ajax call. So far I have gotten all of my social media buttons to refresh with the exception of stumbleupon:

//Refresh Facebook
FB.XFBML.parse(document.getElementById('.socialWrapper'));

//Refresh Twitter
$.ajax({ url: 'https://platform.twitter.com/widgets.js', dataType: 'script', cache:true});

//Refresh LinkedIn
IN.parse()

//Refresh Pinterest
window.parsePins();

//Refresh Google Plus
$.ajax({ url: 'https://apis.google.com/js/platform.js', dataType: 'script', cache:true});

//Refresh SU (Not Working)
$.ajax({ url: 'https://platform.stumbleupon.com/1/widgets.js', dataType: 'script', cache:true});

Solution

  • The stumbleupon script only updates once the badges when the page is loaded. The script also has some checks to only do this for the first time when the script loaded so loading it again with ajax won't help.

    The widgets.js also does not have any publicly documented nice re-loading API like LinkedIn or Pinterest.

    However you can re-execute the badge updates with the following code, with changing the internal state of the STMBLPN object:

    STMBLPN.wasProcessLoaded = false; 
    STMBLPN.processWidgets();