On my page, I have a grid of post thumbnails that are fetched via AJAX and can be filtered. When a user clicks on a thumbnail, a carousel opens with the selected post centered. In this carousel, each post has a LinkedIn share button integrated.
The issue arises when trying to load the LinkedIn share buttons into an invisible element initially and then making it visible later. This causes the buttons not to work properly. To solve this problem, I use the code snippet below:
$.getScript('http://platform.linkedin.com/in.js', function() {
$('.li-box-1').append('<script type="IN/Share" data-counter="right"></script>');
});
However, if I close the carousel, filter the posts, select a different one, and open the carousel again, the LinkedIn share button is missing. Additionally, a warning appears in the console stating:
duplicate in.js loaded, any parameters will be ignored
This warning occurs because LinkedIn's in.js script has already been loaded previously. Does anyone have a solution for this issue?