bootstrap-typeahead.js 在 select 事件上添加一个监听器 [英] bootstrap-typeahead.js add a listener on select event

查看:49
本文介绍了bootstrap-typeahead.js 在 select 事件上添加一个监听器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Bootstrap Twitter 框架的新手,我需要使用 bootstrap-typeahead.js 进行自动完成,但我还需要获取用户为 typeahead 选择的值.

I'm new to the Bootstrap Twitter framework, and I need to use bootstrap-typeahead.js for autocomplete but I need also to get the value selected by the user for the typeahead.

这是我的代码:

<input type="text" class="span3" style="margin: 0 auto;" 
                   data-provide="typeahead" data- items="4" 
                   data-source='["Alabama","Alaska"]'>

如何添加侦听器以从 typeahead 中获取所选值并将其传递给函数?例如,当我使用 ExtJs 时,我应用了这个结构:

How can I add a listener to get the selected value from type typeahead and pass it in a function? For example when I use ExtJs, I apply this structure:

listeners: {
   select: function(value){
     ........
   }
}

如何使用预先输入进行类似操作?

How can I do something similar with a typeahead?

推荐答案

尝试 这个 typeahead 的分支.它为您提供了一个 onselect 事件、异步填充等等!

Try this fork of typeahead. It gives you an onselect event, asynchronous population and more!

这篇关于bootstrap-typeahead.js 在 select 事件上添加一个监听器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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