Dynamic linkedin button is not showing

on with 2 Replies

Oh it’s nightmare! Linkedin share button is not showing up when I load the page content in Ajax. It’s not new to hear!. We always face this kind of issue on every social media buttons  when we do fancy Ajax things with twitter, facebook, etc. But facebook and twitter is some what smart to handle. Linkedin throwing exception  like below when we load “in.js” in Ajax page content.

duplicate in.js loaded, any parameters will be ignored

We just need to check the Linkedin JS is already loaded or not. Below script will make sure Linkedin script duplicate issue. So it did the magic to solve the issue on Ajax content loading. Are done? No. I also try to create the Linkedin button dynamically using Javascript. That eats my hours by frustration.

<script>
	if (typeof (IN) != 'undefined') {
  		// IN.parse(); // old but still supports
 		IN.init(); 	// reinitiating linkedin button  
	} else {
	  $.getScript("http://platform.linkedin.com/in.js");

	}	
</script>

linkedin-frustration

 

 

 

 Photo credit: Marvin Lee (Creative Commons)

When I create the dynamic Linkedin button above trick doesn’t give me hand to solve. But when I do some more research on it. Just found that we can flush the old Linkedin instance by “delete IN;”. So below one works.

<script>
delete IN;
$.getScript("http://platform.linkedin.com/in.js")
</script>

Hope it helps, cheers!

Posted in jQuery and tagged , by .

About Gowri

I am professional web developer with 4+ years experience. PHP, jQuery, WordPress, Magento and Symfony2 are my key skills in web development. I am working with strong enthusiastic team with spirit. We provide all web related solution like HTML/CSS development, Web graphic design and Logo.

2 thoughts on “Dynamic linkedin button is not showing

  1. Mike Wayne

    You are a js god my friend.
    I looked everywhere for this solution and I could not find it anywhere, except for here.

    We spent a good 10 hours trying to figure out how to load this linkedin button while using jquery.

    This worked perfectly. Thank you!

    Reply
  2. Bjrn

    Thanks, looked all over the place for this.
    I used the async script:


    $(function() {
    delete IN;
    $.getScript("http://platform.linkedin.com/in.js?async=true", function success() {
    IN.init({
    onLoad: "onLinkedInLoad",
    api_key: "api_key",
    authorize: true,
    });
    });
    });

    Reply

Leave a Reply to Mike Wayne Cancel reply

Your email address will not be published. Required fields are marked *