在jQuery移动应用程序中更改AddThis共享URL

时间:2014-11-19 17:34:19

标签: javascript jquery facebook jquery-mobile addthis

尝试动态更改要在我的jQuery Mobile应用程序中与AddThis共享的URL时遇到问题。

下面的代码片段中的response.url是Bitly提供的URL,例如“http://shorturl.com/hu7Hnm”但是我无法使用此代码更改URL。我在我们的桌面网站上做同样的事情,这很好,但它不适用于我们的移动网站(由jQuery Mobile驱动)。

Twitter / Facebook /电子邮件弹出窗口仍会显示,但是在之前显示的URL 已被下面的更新代码更改。所以它似乎没有任何影响。

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

social_icons选择器以下面的目标为目标,其中包含AddThis图标。

<ul class="social_icons inline_list">

这是我在页面加载上的共享设置示例:

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

1 个答案:

答案 0 :(得分:1)

我找到了解决方法。它需要在声明开头指定window对象。我相信这是使用jQM的一个怪癖。

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