Events TwitterTypeahead.js,`suggestionsRendered`事件回调,如何获取建议数据? 我如何才能连接到Twitter的Typeahead的suggestionsRendered事件并访问过滤后的数据,以便使用这些数据更新我的表?
我正在使用Twitter Bootstrap 3,这个版本已经将Events TwitterTypeahead.js,`suggestionsRendered`事件回调,如何获取建议数据? 我如何才能连接到Twitter的Typeahead的suggestionsRendered事件并访问过滤后的数据,以便使用这些数据更新我的表?,events,autocomplete,typeahead.js,twitter-typeahead,Events,Autocomplete,Typeahead.js,Twitter Typeahead,我正在使用Twitter Bootstrap 3,这个版本已经将typeahead插件移动到了自己的库中,旧的typeahead插件不再被维护 我已经设置了typeahead,以便按照我的意愿工作,但我有一个问题,我希望库在内部启动suggestionsRendered后启动回调 通过正常方式附加事件不起作用,当前唯一可用的事件位于此处: typeahead:initialized(在typeahead加载(和预取数据)时触发) typeahead:opened(在typeahead建议框打开
typeahead
插件移动到了自己的库中,旧的typeahead插件不再被维护
我已经设置了typeahead,以便按照我的意愿工作,但我有一个问题,我希望库在内部启动suggestionsRendered
后启动回调
通过正常方式附加事件不起作用,当前唯一可用的事件位于此处:
(在typeahead加载(和预取数据)时触发)typeahead:initialized
(在typeahead建议框打开时激发)typeahead:opened
(在typeahead建议框关闭时激发)typeahead:closed
(在选择建议时激发)typeahead:selected
(按tab键或自动完成时触发)typeahead:autocompleted
// This is how you use the above events.
$searchTypeahead.on('typeahead:selected',function(evt,data){
console.log('typeahead:selected');
console.log(data); // Contains the selected items data
});
问题 当有人在输入字段中键入时,我想更新表中的行,我不能在键入时使用上述任何事件来更新表(它们仅适用于单击、选择、悬停等) 如何检索
suggestionsRendered
呈现的过滤数据?(因此,我希望访问所有项目,而不是将其呈现到typeahead框中,这样我就可以对它们进行循环,并将它们添加到表中)
我曾尝试过谷歌搜索(搜索引擎优化):(但找到与旧版(未维护)typeahead相关的信息)
twitter引导程序3预先输入建议呈现自定义事件twitter引导程序3 typeahead suggestionRendered自定义事件
twitter引导程序3预输入建议呈现回调
twitter bootstrap 3 typeahead suggestionsRendered获取数据回调
最后。。我在github上发现一个线程,该线程声明此功能已被请求并正在等待实现(尽管此评论来自10个月前)。目前此功能正在等待实现(以及一系列其他回调),我找到了一个简单的解决方案(需要编辑核心
typeahead.js
库)
第一步
在typeahead.js
中找到以下行(大约行:840
在v0.9.3
中)。步骤2 将上述行更改为: 步骤3 最后,在
HTML
页面(或Javascript
文件)中,使用以下命令附加事件
:
// When you initialize your typeahead, store it into a variable
$typeahead = $('#your-typeahead-input-id-or-class').typeahead({options});
// Access that elements data property, and attach the event to dropdownView
$typeahead.data('ttView').dropdownView.on('suggestionsRendered', function (evtObj) {
console.log(evtObj.type); // Holds the event type: "suggestionsRendered"
console.log(evtObj.data); // Holds results of filtered data: Object
console.log("suggestionsRendered event callback fired");
// Do your stuffs..
});
就这样!
如果您记录
evtObj
var,您将拥有事件类型和数据!:) 目前,这个特性正在等待实现(以及一系列其他回调),我找到了一个简单的解决方案(需要编辑核心typeahead.js
库)
第一步
在typeahead.js
中找到以下行(大约行:840
在v0.9.3
中)。步骤2 将上述行更改为: 步骤3 最后,在
HTML
页面(或Javascript
文件)中,使用以下命令附加事件
:
// When you initialize your typeahead, store it into a variable
$typeahead = $('#your-typeahead-input-id-or-class').typeahead({options});
// Access that elements data property, and attach the event to dropdownView
$typeahead.data('ttView').dropdownView.on('suggestionsRendered', function (evtObj) {
console.log(evtObj.type); // Holds the event type: "suggestionsRendered"
console.log(evtObj.data); // Holds results of filtered data: Object
console.log("suggestionsRendered event callback fired");
// Do your stuffs..
});
就这样!
如果您记录
evtObj
var,您将拥有事件类型和数据!:) 目前,这个特性正在等待实现(以及一系列其他回调),我找到了一个简单的解决方案(需要编辑核心typeahead.js
库)
第一步
在typeahead.js
中找到以下行(大约行:840
在v0.9.3
中)。步骤2 将上述行更改为: 步骤3 最后,在
HTML
页面(或Javascript
文件)中,使用以下命令附加事件
:
// When you initialize your typeahead, store it into a variable
$typeahead = $('#your-typeahead-input-id-or-class').typeahead({options});
// Access that elements data property, and attach the event to dropdownView
$typeahead.data('ttView').dropdownView.on('suggestionsRendered', function (evtObj) {
console.log(evtObj.type); // Holds the event type: "suggestionsRendered"
console.log(evtObj.data); // Holds results of filtered data: Object
console.log("suggestionsRendered event callback fired");
// Do your stuffs..
});
就这样!
如果您记录
evtObj
var,您将拥有事件类型和数据!:) 目前,这个特性正在等待实现(以及一系列其他回调),我找到了一个简单的解决方案(需要编辑核心typeahead.js
库)
第一步
在typeahead.js
中找到以下行(大约行:840
在v0.9.3
中)。步骤2 将上述行更改为: 步骤3 最后,在
HTML
页面(或Javascript
文件)中,使用以下命令附加事件
:
// When you initialize your typeahead, store it into a variable
$typeahead = $('#your-typeahead-input-id-or-class').typeahead({options});
// Access that elements data property, and attach the event to dropdownView
$typeahead.data('ttView').dropdownView.on('suggestionsRendered', function (evtObj) {
console.log(evtObj.type); // Holds the event type: "suggestionsRendered"
console.log(evtObj.data); // Holds results of filtered data: Object
console.log("suggestionsRendered event callback fired");
// Do your stuffs..
});
就这样!
如果您记录
evtObj
var,您将拥有事件类型和数据!:) 我相信这个处理事件的例子现在更相关:我相信这个处理事件的例子现在更相关:我相信这个处理事件的例子现在更相关:我相信这个处理事件的例子现在更相关: