How can i rerender Pinterest's Pin It button?

前端 未结 13 2143
暖寄归人
暖寄归人 2021-01-30 18:14

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

13条回答
  •  既然无缘
    2021-01-30 18:45

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

    
    

    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.

提交回复
热议问题