Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can i rerender Pinterest's Pin It button?

Tags:

I'm trying to create and manipulate the Pin It button after page load. When i change the button properties with js, it should be rerendered to get the functionality of pinning dynamically loaded images. So, does Pinterest have any method like Facebook's B.XFBML.parse() function?

Thanks...

like image 640
onur Avatar asked Feb 19 '12 18:02

onur


People also ask

How do I get the Pin It button on safari?

To install the bookmarklet for use with your Safari browser: Click “View” and then choose “Show Bookmarks” Drag the Pin It button to the Bookmarks Bar. “Pin it” will be displayed by default.


1 Answers

Just add data-pin-build attribute to the SCRIPT tag:

<script defer   src="//assets.pinterest.com/js/pinit.js"   data-pin-build="parsePinBtns"></script> 

That causes pinit.js to expose its internal build function to the global window object as parsePinBtns function.

Then, you can use it to parse links in the implicit element or all of the links on the page:

// parse the whole page window.parsePinBtns();  // parse links in #pin-it-buttons element only window.parsePinBtns(document.getElementById('pin-it-buttons')); 

Hint: to show zero count just add data-pin-zero="1" to SCRIPT tag.

like image 108
Styx Avatar answered Oct 28 '22 23:10

Styx