Reg: Setting Pinterest Button properties through javascript dynamically

nitesh.lakhwani Jul 06, 2012 02:13AM EDT

Hi Paul,

With reference to the questions / answer on the following URL:
http://support.addthis.com/customer/portal/questions/288234-setting-pinterest-button-properties-after-page-load

I too have the similar requirement, but in my case the image is a configurable image (parts of the images can be customized), so the image changes as the configuration is changed.

URL of the site: http://loomdecor.consensusboston.com/beankstalk/custom/tailored-throw-pillow-square.html

I tried the suggestion you provided above i.e. I called the addthis.toolbox('.addthis_toolbox') method and after that dynamically updated the parameters of the pinterest button through javascript as below:
addthis.toolbox(".addthis_toolbox",'',{url: '"'+response.designurl+'"'});
pinItId = $$('a.addthis_button_pinterest_pinit'); pinItId[0].setAttribute('pi:pinit:media', '"'+$('design-url').value+'&hei=400&wid=400"');

Above code makes the changes in the pinterest attributes but the image in the pinterest popup do not get updated, while debugging I found two cases:
1) when we do not provide the value of the attribute "pi:pinit:media" in the tag "<a pi:pinit:media="" />" and if we click the pinit button it will bring the popup containing the images of the current page, and user have to select the particular image to be pinned, and in this AddThis calls a div with id=at16pccImg and appends this div to the end before body element closes, and every time the pinit button is clicked this same div popups with the same images.

2) If we provide the the value of the attribute "pi:pinit:media" in the tag "<a pi:pinit:media="" />" and if we click the pinit button it will bring a popup with the image provided in the attribute, in this case it adds a iframe below the <a pi:pinit:media="" />and sends the image url and other parameters to the iframe and loads a popup, every time the pinit button is clicked it loads the same popup through iframe.

As in my case the attributes of the button needs to be updated each time the image is updated, I would request to please guide me the way I can do the things.

Thanks
Nitesh Lakhwani

Up 0 Rated Down
Paul (AddThis Happiness Specialist) Jul 09, 2012 03:51PM EDT
You need to call the addthis.toolbox() function *after* you update the pi:pinit:media attribute. That should get it to work.

This question is closed to new answers.

Still need help?


General Topics

 

Developers