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.
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. 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). 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. 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.
1) regular:
http://jsfiddle.net/FLAf4/
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. thanks!!
Apparently you cannot set pub-id and async on the addthis script, so you should set
#async=1then set a global variableaddthis_configthat contains the publisher id, also you should have theaddthis_sharevariable in the global scope and then assign the email template and email template variables to that global variable inside of the button click handler.http://jsfiddle.net/joeflateau/Bht2b/4/