I am trying to dynamically change the URL sent by addthis. When a user alters an element it updates a text area containing a custom url so they can return to that url and continue/view their work.
I am creating an addthis button like so(from their API docs):
var addthis_share = {url:"http://www.johndoe.com"}
$(document).ready(function(){
var tbx = document.getElementById("toolbox"),
svcs = {email: 'Email', print: 'Print', facebook: 'Facebook', expanded: 'More'};
for (var s in svcs) {
tbx.innerHTML += '<a class="addthis_button_'+s+'">'+svcs[s]+'</a>';
}
addthis.toolbox("#toolbox");
});
Then when the url is updated I am trying to update the addthis share URL like so:
function updateURL(){
...get some variables here and generate a new url
var newURL="http://the.url.i.want.to.share.com";
$('#tagUrl').val(newURL);
//addthis_share = {url:newURL}
addthis_share = {url:newURL}
addthis.toolbox("#toolbox");
}
The original buttons are getting generated and contain the correct url, but when the url update function executes the addthis share url is not getting updated. How can I force it to update the addthis url?
If you wants to change the addthis url after the html is loaded (in case of ajax or some user events), please use the below hack . Addthis apis are broken as on
[09/04/13 11:42:24 AM]
sunny jhunjhunwala:
addthis.update('share', 'url', 'http://www.sourcen.com');
addthis.url = "http://www.sourcen.com";
addthis.toolbox(".addthis_toolbox");
http://www.sourcen.com ---> new url
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With