Twitter的未捕获类型错误:未定义不是一个函数 [英] Twitter Uncaught TypeError: undefined is not a function

查看:369
本文介绍了Twitter的未捕获类型错误:未定义不是一个函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经收窄我跟我的Twitter的小窗口使用事件的结合具有错误。

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(); });

    twttr.events.bind('tweet', addShared);

似乎产生相同的误差:未捕获类型错误:未定义不是函数。
他们都最终工作,但按钮的表现很奇怪,不时和我想知道如果这个错误有什么关系的问题。

seem to produce the same error: Uncaught TypeError: undefined is not a function. They both ultimately work but the button acts funny from time to time and I'm wondering if this error has anything to do with the problem.

请注意,误差在Chrome检查时,网页上的按钮被点击过之前,但该按钮的工作原理及工作鸣叫但产生的绑定功能不工作了显示出来。这是我最近注意到没有在所有已经改变Twitter的code和问题事件绑定在previously功能。

Note, the error shows up in Chrome when inspecting the webpage before the button is ever clicked but the button works and the tweets work but the resulting bound function does not work anymore. This is a problem that I recently noticed without having changed the twitter code at all and the event binding was previously functional.

任何意见,甚至在看到了同样的问题的确认将是很好,谢谢。

Any advice or even acknowledgement of having seen the same problem would be nice, thanks.

推荐答案

最终被通过@indianburger Twitter的讨论解决的问题。

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

问题是如何code的加载和调用。该解决方案排在的jsfiddle形式: @ indianburer的的jsfiddle

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>

有关参考,这是Twitter的讨论环节。

这篇关于Twitter的未捕获类型错误:未定义不是一个函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆