【问题标题】:How to get reference to input element from within Bootstrap 3 Typeahead callback?如何从 Bootstrap 3 Typeahead 回调中获取对输入元素的引用?
【发布时间】:2017-06-26 23:17:08
【问题描述】:

我正在尝试从 Bootstrap 3 Typeahead (https://github.com/bassjobsen/Bootstrap-3-Typeahead) 回调方法中访问输入元素,但似乎 $(this)、this、$(this)[0] 以及描述的任何其他技术在这个问题上,Get input element from Bootstrap typeahead 不起作用,官方文档中对此一无所知。如果使用包含多个元素的选择器在一个页面上初始化多个 Typeahead 实例,这一点非常重要,但在每个回调中只应处理相关的单个元素。

$(".typeahead").typeahead({
   afterSelect: function(item) {
      // the only parameter, item, is the JSON of the 
      // currently selected item, chosen from the list.
      // Neither $(this) nor this are references to the 
      // affected input element, so how do I access the 
      // input element from within this callback?
   },
   ...
});

【问题讨论】:

    标签: jquery twitter-bootstrap-3 typeahead.js bootstrap-typeahead twitter-typeahead


    【解决方案1】:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2012-09-06
      • 1970-01-01
      • 1970-01-01
      • 2019-12-01
      • 2016-04-11
      • 2015-12-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多