Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/474.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何提交从typeahead Hound auto complete填充的数据_Javascript_Bootstrap Typeahead_Typeahead.js_Bloodhound - Fatal编程技术网

Javascript 如何提交从typeahead Hound auto complete填充的数据

Javascript 如何提交从typeahead Hound auto complete填充的数据,javascript,bootstrap-typeahead,typeahead.js,bloodhound,Javascript,Bootstrap Typeahead,Typeahead.js,Bloodhound,如何提前提交数据 下面是JSFIDLE上的相关代码 守则副本: var numbers = new Bloodhound({ datumTokenizer: function(d) { return Bloodhound.tokenizers.whitespace(d.num); }, queryTokenizer: Bloodhound.tokenizers.whitespace, local: [ { num: 'one' }, { num: 'two' }, { num: 'three'

如何提前提交数据

下面是JSFIDLE上的相关代码

守则副本:

var numbers = new Bloodhound({
datumTokenizer: function(d) { return Bloodhound.tokenizers.whitespace(d.num); },
queryTokenizer: Bloodhound.tokenizers.whitespace,
local: [
{ num: 'one' },
{ num: 'two' },
{ num: 'three' },
{ num: 'four' },
{ num: 'five' },
{ num: 'six' },
{ num: 'seven' },
{ num: 'eight' },
{ num: 'nine' },
{ num: 'ten' }
]
});

// initialize the bloodhound suggestion engine
numbers.initialize();

// instantiate the typeahead UI
$('.typeahead').typeahead(null, {
displayKey: 'num',
source: numbers.ttAdapter(),
updater: function(item) {
    alert(item);
}
});

它似乎没有进入更新程序功能

Typeahead.js没有“更新程序”选项

相反,您可以编写一个事件处理程序,它将使用typeahead的选定事件(即typeahead:selected),例如

可在此处找到一个工作示例:


没关系,我知道了。你能告诉我怎么做吗?@AnilKumarMuppalla,本·史密斯指出
var numSelectedHandler = function (eventObject, suggestionObject, suggestionDataset) {
    alert(suggestionObject.num);
};

typeahead.on('typeahead:selected', numSelectedHandler);