I have configured ShareThis to display the Multi-Post Widget with horizontal counters in the Links area of my article nodes. This works fine in the node pages and also the teasers, including teasers in views. But when I have to paginate the view, any subsequent view pages are missing the ShareThis widget. The link remains with the other widgets in the link, but the ShareThis widget is missing. When I return to the first page, the ShareThis widgets are still there.

AJAX is turned ON for this view display. I have no other paginated views on the page.

Comments

tomogden’s picture

Issue summary: View changes
tomogden’s picture

Title: ShareThis link in teasers disappears in Views when navigating to paginated pages. » ShareThis link widget fails to render with AJAX pagination.
Gaofengzzz’s picture

Currently, this module do not support pages from ajax call. But this is a workaround way, you can try to reload sharethis widget from your custom js code. below is code example:

Drupal.behaviors.ajaxShow = {
  attach: function (context) {
		
	//sharethis
  if (typeof(stButtons) != "undefined") {
    stButtons.locateElements();
  }
 } 
}
tomogden’s picture

Thank you, @gaofengzzz. In fact, this does bring the icon back, but the stats that go with it are still missing. I wonder if we could take this a step further?

Gaofengzzz’s picture

Hi, @tomogden. Weird, I can not reproduce this issue. The icon and stats appear togethor in my env.

tomogden’s picture

Perhaps you might divine some idea from what I am seeing. Here it is in my staging site, http://stage.blogs.state.gov/ .

  1. Scroll down to Latest Stories block of teasers.
  2. Click the right arrow (">") button in the top right corner of the block and note the share counts are missing in the following page, although with your script placed in the theme's javascript file, we now have the ST button and all the other elements.
  3. Click the left arrow ("<") button and note the share counts are now missing in the original page.

All the elements and CSS appear to be there, but the digit in <span class="stBubble_hcount"></span> is just gone.

Contrast this from the page of teasers at http://stage.blogs.state.gov/latest-stories where changing pages does not affect the shares. It is the same view with a different display, but with AJAX turned off.

Gaofengzzz’s picture

I used firebug in your stage. Found out that the count data is correctly received when clicking the pagenation. But for some reason, the share counts do not been rendered sometimes. Sorry, i have no idea about this currently, i just guess this issue might related cache problem somewhere.

jatorresdev’s picture

#3 worked for me, thanks

iamgotah’s picture

Which code did you write instead of "//sharethis"? I tried with ShareThisForm.js without success.
I added scripts[] = my_script.js to my theme.info file too.

I really manage very badly with javascript :S

mckinzie25’s picture

This thread is old, but I had a similar problem to what @tomogden reported in #4. I used the code supplied by @gaofengzzz in #3, and the ShareThis icons showed up, but not the share count numbers themselves. To get it to work, I did this:

Drupal.behaviors.ajaxShow = {
  attach: function (context) {

  //sharethis
  if (typeof(stButtons) != "undefined") {
    setTimeout(function() {

      stButtons.locateElements();

    }, 1000);
  }
 }
}

It's possible that the code above was running too soon, before the new content had finished being created and populated, so using setTimeout() allows the code to wait until everything is ready before getting the sharecount numbers. It's possible that without setTimeout(), the code was trying to populate a div that didn't exist yet.

Obviously, adjust the timeout to whatever you need.