Welcome, Guest Sign In

Email template when using AJAX (bug)

danielcampos Mar 21, 2012 08:52AM EDT

In fact, it's not a question, but the description of a bug and how I solved it.

One of my projects is using the AddThis sharing buttons in some screens, and since the application is entirely in AJAX, the AddThis should be loaded and restarted every time.

Well, a lot of ways about how to do that can be found through Web (some code of how to do that, below... where is YOUR-ID, put your id, for example ra-4asd2...). The problem itself was using custom templates for the email functionality.

var script = '';
if (window.addthis){
window.addthis = null;
$.getScript( script , function() { addthis.init(); });

I tested a lot of ways, but the new default template or the configured template wasn't used when loading dynamically the AddThis library, it only worked on normal non-AJAX requests.

Analysing over and over again, I've found some parameter that was blank, when the template wasn't used, but with my ID in a successfully sharing email: the parameter 'pub'
Hey! So that's the problem, the AddThis didn't know what account was trying to make the request so it didn't find the right template and used the standard.

So my solution was set the pubid manually every time the AddThis is reloaded, so that value is used to populate the parameter 'pub' and the right profile template is got :)
I can do that with line below (again, where is YOUR-ID, put your id, for example ra-4asd2...):

var addthis_config = { pubid: 'YOUR-ID'};

And everything worked as it should :)

I didn't find anything regarding this problem or solution in documentation. So I guess it should be done automatically or something written in the AJAX section of API documentation.

I hope it helps someone.

Daniel Campos

Up 0 Rated Down
Paul (AddThis Happiness Specialist) Mar 21, 2012 10:51AM EDT
Thanks for documenting this! I'm sure it will help someone.

This question is closed to new answers.

Still need help?

  • Call Us @ 888.555.1212

General Topics