Changing the AddThis shared URL in a jQuery mobile application

450 views Asked by At

I am experiencing an issue when attempting to dynamically change the URL to be shared with AddThis in my jQuery Mobile application.

The response.url in the code snippet below is a Bitly-provided URL such as "http://shorturl.com/hu7Hnm" however I am unable to change the URL with this code. I do the same thing on our Desktop site and this works fine, however it does not work on our Mobile site (which is jQuery Mobile powered).

The Twitter/Facebook/Email pop-ups still appear, however they show the URL before it has been changed by the update code below. So it does not appear to have any affect.

// update the AddThis share url to the shortened URL
addthis.update('share', 'url', response.url);
addthis.url = response.url;
addthis.toolbox('.social_icons');

The social_icons selector targets this below which holds the AddThis icons.

<ul class="social_icons inline_list">

This is an example of my sharing setup on page load:

var addthis_share = {
      url: "http://www.wrestlemaniamainevent.com/shared/huih897897jkhjkh98907908nn",
      title: "Check out the Main Events at www.wrestlemaniamainevent.com"
}
1

There are 1 answers

0
crmpicco On BEST ANSWER

I found the solution to this. It requires specifying the window object at the start of the declaration. I believe this is a quirk of using jQM.

window.addthis.toolbox('.social_icons', {}, {'url': response.url });