Skip to content

Instantly share code, notes, and snippets.

@machu
Created August 18, 2011 14:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save machu/1154197 to your computer and use it in GitHub Desktop.
Save machu/1154197 to your computer and use it in GitHub Desktop.
jQueryのソーシャルボタンプラグインを2回以上呼び出したときに、Google+ボタンがa表示されない問題へのパッチ
diff --git a/js/jquery.socialbutton.js b/js/jquery.socialbutton.js
index d4bb90c..03ca664 100644
--- a/js/jquery.socialbutton.js
+++ b/js/jquery.socialbutton.js
@@ -731,7 +731,11 @@ function socialbutton_google_plusone(target, options, defaults, index, max_index
script_params = '{' + script_params + '}';
}
- $('body').append('<script type="text/javascript" src="https://apis.google.com/js/plusone.js">' + script_params + '</script>');
+ if (typeof gapi === "undefined" || typeof gapi.plusone === "undefined") {
+ $('body').append('<script type="text/javascript" src="https://apis.google.com/js/plusone.js">' + script_params + '</script>');
+ } else {
+ gapi.plusone.go();
+ }
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment