简体   繁体   English

通过ajax addthis.com加载按钮(能够动态设置电子邮件变量)

[英]addthis.com load button via ajax (to be able to set email variables dynamically)

i am trying to load and initialize the addthis.com widget via ajax in order to be able to reset the email variables inside the addthis_share object dynamically based on user input. 我试图通过ajax加载并初始化addthis.com小部件,以便能够根据用户输入动态重置addthis_share对象内的电子邮件变量。

so far i am succeeding in loading the widget via ajax, but when i load it via ajax the button which i need the most is no longer part of the widget. 到目前为止,我已经成功通过ajax加载了小部件,但是当我通过ajax加载时,我最需要的按钮不再是小部件的一部分。 this is very strange as i am using the exact same script to load both widgets. 这很奇怪,因为我使用完全相同的脚本来加载两个小部件。

the button which i need is the 'Email' button. 我需要的按钮是“电子邮件”按钮。 the widget itself has two email buttons: one is called 'Email' and the other one is called 'Email App'. 小部件本身有两个电子邮件按钮:一个称为“电子邮件”,另一个称为“电子邮件应用程序”。 the 'Email' one is the one which accepts variables which are passed to emails (and the one which is not showing up when i load it via ajax). “电子邮件”是一种接受传递给电子邮件的变量的变量(而当我通过ajax加载时,该变量不会显示)。 you can verify what email buttons are part of the widget after it loads by: clicking on the widget (on the + button itself) and typing 'email' in the search input field. 您可以通过以下方式验证窗口小部件中包含哪些电子邮件按钮:单击窗口小部件(在+按钮本身上),然后在搜索输入字段中输入“电子邮件”。

i have setup two js fiddles to illustrate the case. 我设置了两个js小提琴来说明这种情况。 the first one loads the widget in the standard way (and you can see both email buttons there). 第一个以标准方式加载小部件(您可以在此处看到两个电子邮件按钮)。 the second one loads the widget via jQuery getScript and you can see that only the 'Email App' button shows up in it. 第二个通过jQuery getScript加载小部件,您可以看到只有“电子邮件应用程序”按钮显示在其中。

1) regular: http://jsfiddle.net/FLAf4/ 1)常规: http//jsfiddle.net/FLAf4/

2) ajax: http://jsfiddle.net/6QUWt/5/ 2)ajax: http : //jsfiddle.net/6QUWt/5/

i know that this is addthis.com specific question -- i tried posting this question on customization/q&a part of their website and so far nobody has commented on it. 我知道这是addthis.com特有的问题-我尝试将这个问题发布在其网站的定制/常见问题解答的一部分上,到目前为止,还没有人对此发表评论。 thanks!! 谢谢!!

Apparently you cannot set pub-id and async on the addthis script, so you should set #async=1 then set a global variable addthis_config that contains the publisher id, also you should have the addthis_share variable in the global scope and then assign the email template and email template variables to that global variable inside of the button click handler. 显然,您无法在addthis脚本上设置pub-id和async,因此您应该设置addthis_config #async=1然后设置一个包含发布者ID的全局变量addthis_config ,并且还应该在全局范围内具有addthis_share变量,然后分配电子邮件模板和通过电子邮件将模板变量发送到按钮单击处理程序内部的全局变量。

http://jsfiddle.net/joeflateau/Bht2b/4/ http://jsfiddle.net/joeflateau/Bht2b/4/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM