Skip to content Skip to sidebar Skip to footer

Twitter Uncaught TypeError: Undefined Is Not A Function

I have narrowed down the error I am having with my Twitter widget usage to the binding of the event. twttr.events.bind('tweet', function (event) { addShared(); }); or twttr.ev

Solution 1:

The issue ended up being solved on Twitter's discussions by @indianburger.

The problem was how the code was being loaded and called. The solution came in the form of a jsfiddle: @indianburer's jsfiddle.

If that is broken, the simplest example of what is needed for event binding is:

<a href="https://twitter.com/share" class="twitter-share-button" data-url="https://twitter.com/share" data-via="josephjohnbless">Tweet</a>
<script>
  window.twttr = (function (d,s,id) {
      var t, js, fjs = d.getElementsByTagName(s)[0];
      if (d.getElementById(id)) return; js=d.createElement(s); js.id=id;
      js.src="https://platform.twitter.com/widgets.js";
      fjs.parentNode.insertBefore(js, fjs);
      return window.twttr || (t = { _e: [], ready: function(f){ t._e.push(f) } });
  }(document, "script", "twitter-wjs"));
</script>
<script>
    twttr.ready(function (twttr) {
        twttr.events.bind('click', function (event) { alert('yes'); });
    });
</script>

For reference, this is the Twitter discussion link.


Post a Comment for "Twitter Uncaught TypeError: Undefined Is Not A Function"