I’m testing a application that I custom building. So the tweet button will show within the contents of a post or page. But AddThis also adds a tweet button at the bottom or each post / page.
If I do NOT have AddThis show (with tweet button) on the WordPress page the twttr.events.bind follow & tweet twttr.events.bind events fire just fine.
But when I have the AddThis appear on a page it doesn’t work anymore. The tweet pop-up box opens and tweets just fine but the twtter.events.bind never fires.
I tried to remove this when AddThis is enabled for the page. Just in case it was being loaded twice but still the same issue.
<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
BUT if I have AddThis enabled for the page and NOT have the tweet button show up so the tweet button I’ve created shows within the content of the post / page it works… So the issue is when there are 2 tweet buttons. One from me within the content and another from AddThis at the end of the post / page.
Any ideas?
Here is the full code:
<script type="text/javascript" src="http://platform.twitter.com/widgets.js"></script>
<script type="text/javascript">
twttr.events.bind('tweet', function(event) {
alert("Twitter Lottery Entry Successful");
});
twttr.events.bind('follow', function(event) {
document.getElementById("twitterStep1").style.display = "none";
document.getElementById("twitterStep2").style.display = "block";
});
</script>
<a href="http://twitter.com/share" class="twitter-share-button"
data-url="'.$cb_tweet_lottery1_url.'"
data-text="'.$cb_tweet_lottery1_txt.'"
data-count="none">Tweet</a>
And here is the code that AddThis adds:
<!-- AddThis Button BEGIN -->
<script type="text/javascript">
//<!--
var addthis_product = 'wpp-250';
//-->
</script>
<div class="addthis_container addthis_toolbox addthis_default_style" addthis:url="http://www.mysite.net/lottery-1/" addthis:title="Lottery 1"><a href="http://www.addthis.com/bookmark.php?v=250&username=ps3blogdotnet" class="addthis_button_compact"></a><a class="addthis_button_tweet"></a><a class="addthis_button_facebook_like"></a><a class="addthis_button_google_plusone"></a><script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=ps3blogdotnet"></script></div>
<!-- AddThis Button END -->