Rendering toolboxes in a list

giftflow Mar 06, 2012 11:21AM EST

Hello Addthis,

I love your service so much! Your API is solid. I just need help debugging a few things.

I have a list of objects and would like to render a toolbox for each object in the list.

Here is my code below. I can get it to render buttons but not toolboxes. So I have two questions.

1. Why does it render buttons but not toolboxes?
2. How do I reconcile my global share configurations (url shortening, etc) with my row-level specific share configs (url, title, image)?

//Here is the inline code for each list element
//THE FORM KEPT ALERTING 'INVALID CHARACTERS' SO I LEFT OUT THE PROPER HTML SYNTAX
div id='unique object id' class='addthis addthis_toolbox addthis_default_style' close div




//Here are my global javascript objects
var addthis_config = {
87 pubid: 'My Addthis username',
88 services_compact: 'facebook,twitter,tumblr,email'
89 }

var addthis_share = {
91 url_transforms: {
92 clean:true,
93 shorten: {
94 twitter: 'bitly',
95 facebook: 'bitly'
96 }
97 },
98 shorteners: {
99 bitly: {
100 login: 'MYLOGIN',
101 apiKey: 'MYAPIKEY'
102 }
103 }
104 }
//The URL shortening is not working


//Here I iterate through the list and create a button for each list element with data specific to the object

155 var goods = $('.goods_list').children('li.clearfix');
156 $.each(goods, function(foo, bar){
157 myurl = $(bar).find('a.title').attr('href');
158 mytitle = $(bar).find('a.title').text();
159 mydescription = $(bar).find('span.summary').text();
160 myimage = $(bar).find('img.thumb_image').attr('src');
161 myid = $(bar).find('div.addthis').attr('id');
168
//HERE is my first issue - how do I have both a global addthis_share and specify these values for each row? Can I merge to two objects?
169 addthis_share = {
170 url: $.trim(myurl),
171 title: $.trim(mytitle),
172 description: $.trim(mydescription)+'...',
173 image: $.trim(myimage)
174 };
175
179 addthis.toolbox('#'+myid, addthis_config, addthis_share);
//All this does is add a div class='atclear'. But the button method works...

Up 0 Rated Down
giftflow Mar 06, 2012 11:25AM EST
ok still not indented but at least the line numbers are gone
Up 0 Rated Down
giftflow Mar 06, 2012 11:25AM EST
hahah I forgot to hide my API key - NOOOOOOOO
Up 0 Rated Down
giftflow Mar 06, 2012 11:51AM EST
Ok i added the <a links to the toolbox and now its working!

But I can't get my bitly URL shortener to work and the content its trying to share is weak - no description or image
Up 0 Rated Down
giftflow Mar 06, 2012 11:53AM EST
Although your API documentation says all you need to dynamically render a toolbox, all you need is the div tag

Post Your Public Answer

Your name (required)
Your email address (required)
Answer (required)

Still need help?


General Topics

 

Developers