maxlk
maxlk

Reputation: 1057

Sharethis doesn't load with AJAX

I am using jquery infinity scroll and jquery masonry plugin on one my projects and also I an using a Sharethis buttons on the pages.

problem is that the Sharethis button dosen't load on the 2nd page, which is loaded using ajax. I am using normal Sharethis code

<script type="text/javascript" src="http://w.sharethis.com/button/buttons.js"></script>
<script type="text/javascript">stLight.options({publisher: "ur-de6b7a4a-e967-4778-5476-54ab547cb1bb", doNotHash: false, doNotCopy: false, hashAddressBar: false});</script>


<span class='st_facebook_hcount' st_url="http://<?php echo $settings['siteurl'];?>/listing-<?php echo $row['id'];?>-<?php echo $PageLink;?>.html" st_title="<?php echo $LongTitle;?>" displayText='Facebook'></span>
<span class='st_twitter_hcount' st_url="http://<?php echo $settings['siteurl'];?>/listing-<?php echo $row['id'];?>-<?php echo $PageLink;?>.html" st_title="<?php echo $LongTitle;?>" displayText='Tweet'></span>
<span class='st_pinterest_hcount' st_url="http://<?php echo $settings['siteurl'];?>/listing-<?php echo $row['id'];?>-<?php echo $PageLink;?>.html" st_title="<?php echo $LongTitle;?>" displayText='Pinterest'></span>

Can anyone tell me a fix for this? did search everywhere but couldn't find an answer.

Upvotes: 1

Views: 1188

Answers (3)

Vikash Kumar
Vikash Kumar

Reputation: 222

Call this function on Ajax success

stButtons.locateElements();

i.e:

success: function (response) {
  .............
  Your Code
  .............
  stButtons.locateElements();
}

Upvotes: 0

Ibnul Hasan
Ibnul Hasan

Reputation: 471

I was facing the same problem with sharethis and Ajax pagination. The buttons was not showing after posts loaded by Ajax so I've searched and found this. I've just added the function stButtons.locateElements(); on Ajax success:

something like success: stButtons.locateElements();

Hope this will be helpful for someone like me.

Thanks

Ibnul

Upvotes: 1

maxlk
maxlk

Reputation: 1057

I just found out that you can use stButtons.locateElements(); fix this this problem. thank everyone for your time.

Upvotes: 3

Related Questions