获取Bootstrap提前输入的选定项目值 [英] Get selected items value for Bootstrap's typeahead
本文介绍了获取Bootstrap提前输入的选定项目值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Bootstrap刚刚实现了一项名为typeahead的简洁的自动完成功能.我在获取适当的文本输入值时遇到麻烦.
Bootstrap just implemented a neat autocomplete feature called typeahead. I am having trouble getting the appropriate value for the text input.
例如,我可能有以下内容:
For instance, I might have the following:
$('input').on('change', function(){
console.log($(this).val());
});
这似乎没有捕获所选值.有人知道如何通过Bootstrap使用typeahead获得所选值吗?
This does not appear to capture the selected value. Does anyone know how to get the selected value using typeahead with Bootstrap?
推荐答案
$('#autocomplete').on('typeahead:selected', function (e, datum) {
console.log(datum);
});
$('#autocomplete').on('typeahead:cursorchanged', function (e, datum) {
console.log(datum);
});
似乎预先输入已更改的侦听器和用法没有充分记录.您可以使用这些侦听器.
Seems Typeahead changed listeners and usages are not well documented. You can use these listeners.
更新
在更高版本中,事件名称已更改为typeahead:select
.
Event name was changed to typeahead:select
in later versions.
这篇关于获取Bootstrap提前输入的选定项目值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文