我正在使用带有多个数据集的Typeahead.js,如下所述。我没有使用猎犬,所以我的代码看起来有些不同,如下所示
$('#search .typeahead').typeahead({
hint: true,
highlight: true,
minLength: 1
},
{
name: 'football_team',
source: substringMatcher(football_teams),
templates: {
header: '<h3>Football teams</h3>'
}
},
,{
name: 'basketball_team',
source: substringMatcher(basketball_teams),
templates: {
header: '<h3>Basketball teams</h3>'
}
});
由于使用数据集football_teams
和basketball_teams
,因此我想根据使用了哪个数据集来发送其他获取请求。例如,如果我搜索"阿森纳",请选择它并单击Enter,它应该发送folllow Request ?football_team=Arsenal
。
如何根据使用了哪个数据集设置输入字段的name
属性?
我认为实施真的很容易,但是在谷歌搜索一段时间后,我找不到任何东西...
使用cdn-ref尝试使用custom-event
处理程序进行打字:选择用于处理选定选项
用法参考:样本代码(内部proj(