javascript - 处理 Typeahead 和外部 JSON 输入不起作用
问题描述
处理搜索框的预输入功能,我在 js 文件中手动定义术语。而不是这个,我需要通过 url 从外部解析对data:[ ]的 json 响应。我怎样才能做到这一点。
jQuery.typeahead({
input: '.js-typeahead-search_v1',
order: "desc",
source: {
data: [
"Andorra", "Angola", "Antigua and Barbuda",
"Uzbekistan", "Vanuatu", "Venezuela", "Vietnam", "Yemen", "Zambia", "Zimbabwe"
]
},
callback: {
onInit: function (node) {
console.log('Typeahead Initiated on ' + node.selector);
}
}
});
解决方案
推荐阅读
- python - Django没有显示正确设置的图像
- tcl - 将 2 个文件与 TCL 与多个匹配项进行比较
- jquery - 在模式关闭时捕获事件
- php - 通用的“stdClass”在 PHP 中代表什么?
- c# - 垂直滚动上的 WPF DataGrid 固定或粘滞标题
- data-structures - 如何解决以下动态规划问题
- unix - java 16 中的 UNIX 域套接字通道是什么?它们如何有用
- php - 在 PHP 中通过邮件发送附件
- javascript - 如何在使用 React 测试库的集成测试中避免“行为”警告
- ios - 如何在一个Viewcontroller下设置xib视图的IBAction(这个xib视图下会有视图A和视图B)