Domanda

I am running into an issue where I am making an AJAX call to load images into a carousel, and it is breaking the shareThis click/hover events that are associated with each image (email, twitter, and facebook).

I have read all over that by doing

stButtons.locateElements();

it should resolve the issue, but it does not. Nothing happens and the buttons remain unclickable/no hover event. I have also tried reloading the script:

var switchTo5x = true;
$.getScript('//ws.sharethis.com/button/buttons.js', function () {
   stLight.options({ "publisher": "publisher-code" }); 
});

and that just leads to button.js throwing this error: "Uncaught TypeError: Cannot call method 'process' of null".

Any thoughts on how I can rebind the events?

È stato utile?

Soluzione

I ended up figuring out a solution, although there is still an error being thrown by button.js.

Before I run getScript, I set stButtons to null and that solved my issue. Here was the end result:

if (stButtons) {

    // Reset the share this buttons to null
    stButtons = null;
    try {
       // Reload the script from scratch
       var switchTo5x = true;
       $.getScript('//ws.sharethis.com/button/buttons.js', function () {
           stLight.options({ "publisher": "pub-id" });
       });
    }
    catch (err) { }
}

I am still getting this error from button.js: Uncaught TypeError: Cannot read property 'messageQueueInstance' of null. But, it is working now. Will look more into this error another time.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top