我有两个预先输入的输入框。这是两者的代码。
$('#input1').typeahead({
name: 'DrugName',
remote: {
url: 'Model/Dataset1.js',
filter: function (parsedResponse) {
// do whatever processing you need here
return parsedResponse;
}
},
valueKey: "DrugName",
template: [
'<div class="typeahead-dropdown">',
'<p class="tt-drugname">{{DrugName}}</p>',
'</div>',
].join(''),
engine: Hogan
});
第二 :
$('#input2').typeahead({
name: 'Name',
remote: {
url: 'Model/Dataset2.js',
filter: function (parsedResponse) {
// do whatever processing you need here
return parsedResponse;
}
},
valueKey: "Name",
template: [
'<div class="typeahead-dropdown">',
'<p class="tt-drugname">{{DrugName}}</p>',
'</div>',
].join(''),
engine: Hogan
});
第一个工作正常,但第二个在我选择下拉选项时返回此错误。
Error: one of local, prefetch, or remote is required
我试过有遥控器,但我仍然收到错误。我相信代码没有错。任何人都可以帮我解决代码吗?
回答这个问题
即使您提供了本地、预取或远程源,如果您收到错误Error: one of local, prefetch, or remote is required
.. 问题不在 JavaScript 代码中..
我通过编辑 Input DOM 元素来修复它。
那是<input type="text" class="tw-typeahead" autofocus="autofocus" />
以前。我把它改成<input type="text" class="tw-typeahead" />
..
删除自动对焦属性修复了所有错误。很奇怪,但这就是问题所在。我与代码斗争了 2 天,但终于找到了!..
谢谢,
拉胡尔·帕蒂尔