I was getting the following JS error message when adding multiple sharethis widgets to a single page:

TypeError: stButtons.messageQueueInstance is null

I found this on StackOverflow: http://stackoverflow.com/a/12363869/197375. It turns out that including the buttons.js script from sharethis more than once causes problems. So here's a patch that only includes the buttons.js script once.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Lythimus’s picture

Thanks. I was receiving this error when using colorbox_node.module and this patch appears to have resolved it. I recommend pushing into dev branch.

Chaulky’s picture

You really just need to use drupal_add_js instead of writing out the script tag. Drupal will not duplicate external JS files added using drupal_add_js.

steven.wichers’s picture

Status: Active » Needs review
FileSize
1.94 KB

Here's a patch that uses drupal_add_js() instead of

tags for the ShareThis service. It does not convert the configuration screen to use #attached instead of inlining javascript inside a div.
steven.wichers’s picture

Version: 7.x-2.x-dev » 7.x-2.5

Status: Needs review » Needs work

The last submitted patch, sharethis-use_drupal_add_js-1784128-3.patch, failed testing.

steven.wichers’s picture

Version: 7.x-2.5 » 7.x-2.x-dev
Status: Needs work » Active

I just checked out the 2.x-dev branch and the code is too different to apply the patch to. The patch I provided will apply cleanly to the 2.5 release, but is not useful for continued development. I made a patch for the dev branch (that includes using #attached for the form related javascript), but because the dev branch uses theme() for including the javascript and ShareThis elements it is open to caching problems. drupal_add_js() will not include the javascript when serving up a cached tpl. The proper way to do this is to use a render array with the #attached attribute including the necessary scripts. Doing it in this manner will ensure Drupal only includes scripts once, and they get included even if the theme output gets cached.

Gaofengzzz’s picture

Status: Active » Needs review
FileSize
3.22 KB

create patch for this issue.

Gaofengzzz’s picture

Status: Needs review » Fixed

This patch is commited in d521c49.

Please let me know if you would have any further comments, feedback, questions, issues, objections, suggestions or concerns on any aspects in the commits or this ticket in general, I would be glad to provide more information or explain in more details.

Cheers!

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.