我有两个预先输入框..这是两者的代码。
$('#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代码中.. < / p>
我通过编辑Input DOM元素来修复它。
之前是<input type="text" class="tw-typeahead" autofocus="autofocus" />
。我将其更改为<input type="text" class="tw-typeahead" />
..
删除自动对焦属性修复了所有错误..很奇怪,但这是问题所在。我和代码争取了2天,但终于找到了它!..
谢谢,
Rahul Patil
答案 0 :(得分:3)
如果您收到错误 Error: one of local, prefetch, or remote is required
,即使您提供了本地,预取或远程来源..问题不在JavaScript代码中.. < / p>
我通过编辑Input DOM元素来修复它。
之前是<input type="text" class="tw-typeahead" autofocus="autofocus" />
。我将其更改为<input type="text" class="tw-typeahead" />
..
删除自动对焦属性修复了所有错误..很奇怪,但这是问题所在。我和代码争取了2天,但终于找到了它!..
谢谢,
Rahul Patil