Question

I'm using the sharethis hover widget (display:fixed) together with jQuery Address on an one-page app. All requests are pushState and loaded through ajax. So when a user goes from pageA.html to pageB.html the address is updated through pushState. When i however click on a certain page on "share to facebook", the page where i entered the website is being shared instead of the current one. The phenomenon can be seen on this website.

I've searched in the stWidget object where the url, title, etc is being stored but i can't find it. Sharethis is being really secretive about it and keeps referring to this page but that only explains how to activate the widget in the ajax loaded content, not how to update the widget with the new address, title, etc or how to modify it likewise.

Was it helpful?

Solution

In the end i made a handler like this. It's stupid though since it removes the buttons and adds them up again instead of just changing the variables. Still i don't understand why they're so secretive about such a simple procedure as refreshing the buttons' vars.

function updateShareThisButtons() {

    var services = [];
    services.push("facebook", "googleplus","twitter","pinterest", "email", "sharethis");
    if($('#sthoverbuttons-chicklets').length == 0)
        $('.sthoverbuttons-chicklets').attr('id','sthoverbuttons-chicklets')

    $('#sthoverbuttons-chicklets').html('');
    for (var i = 0; i < services.length; i++) {
          stWidget.addEntry({"service":services[i],"element":document.getElementById('sthoverbuttons-chicklets'),"url":$.address.baseURL(),"title":$.address.title(), "type":"large","summary":"summary"});
    };
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top