tagsinput& typeahead:无法读取未定义的属性“apply” [英] tagsinput & typeahead: Cannot read property 'apply' of undefined

查看:115
本文介绍了tagsinput& typeahead:无法读取未定义的属性“apply”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试使用tagsinput&时遇到此错误打字。

I keep getting this error when trying to use tagsinput & typeahead.

html:

<section id="examples">
  <div class="example example_typeahead">
    <h3>Typeahead</h3>
    <div class="bs-example">
      <input class="testing" type="text" value="nope" />
    </div>
  </div>
</section>

javascript:

javascript:

var data = ['yes', 'yesyes', 'no', 'nope', 'yes again'],
  elt = $('.testing');

elt.tagsinput({
  typeahead: {
    source: data
  },
});

点击列表中的项目后,我收到了应用错误。我还注意到我输入的文字没有删除。
我搜索了其他类似问题,但未找到合适的答案。

I get the apply error after clicking on an item in the list. I also notice that the text I typed isn't removed. I have searched for other similar issues but didn't find a working answer.

注意:我正在使用此插件对于预先输入 https://github.com/bassjobsen/Bootstrap-3-Typeahead
和此插件用于tagsinput http://bootstrap-tagsinput.github.io/bootstrap -tagsinput / examples /

note: I'm using this plugin for typeahead https://github.com/bassjobsen/Bootstrap-3-Typeahead and this plugin for tagsinput http://bootstrap-tagsinput.github.io/bootstrap-tagsinput/examples/

推荐答案

,但我不确定,那个已经有一个bootstrap-tagsinput更新,它以某种方式破坏了它对待旧的bootstrap typeahead的方式。我发现了两个错误,但没有完全找到原因。

I guess, but am not sure, that there has been made a bootstrap-tagsinput update which somehow broke the way it treats the "old" bootstrap typeahead. I have found two bugs, but not tracked completely down why.

第一个问题

错误无法读取属性'apply'of undefined 在typeahead中引发,是由尝试定位未定义值的typeahead引起的。问题是 此处 。我为此制作了 拉取请求 (点击查看更多细节)。希望我的建议将合并,如果没有,你可以下载 this 分叉回购。 拉取请求现在合并为主。

1'st issue
The error "Cannot read property 'apply' of undefined" is raised in typeahead and is caused by the typeahead trying to target a undefined value. The issue is here as well. I have made a pull request for this (click for details). Hopefully my suggestion will be merged, if not you can download this forked repo. The pull request is now merged into master.

第二期

当讨厌的例外是历史时,我注意到在typeahead中做出选择后,bootstrap-tagsinput没有清理。进行选择但是整个字符串或字符串的一部分保留在输入框中。这可以通过使用 afterSelect 处理程序来解决:

$('#someElement').tagsinput({
  typeahead: {
    source: data,
    afterSelect: function() {
       this.$element[0].value = '';
    }
  }
}) 

通过这两个更改,bootstrap-tagsinput和boostrap3-typeahead按预期工作。请参阅演示 - > http://jsfiddle.net/bao3vk2m/

With these two changes, bootstrap-tagsinput and boostrap3-typeahead works as expected. See demo -> http://jsfiddle.net/bao3vk2m/

这篇关于tagsinput&amp; typeahead:无法读取未定义的属性“apply”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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