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?
window.location.reload()
– Rudderaddthis_share
looks like to be global. You should try reloading the AddThis plugin or see if you can change the url in the DOM directly. – Rudder