Twitter Typeahead.js,“需要本地,预取或远程之一“即使提供 [英] Twitter Typeahead.js, " one of local, prefetch, or remote is required" even if provided
问题描述
我有两个预先输入框..这是两者的代码。
I have two typeahead input boxes.. Here's the code for both.
$('#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
});
第一个工作正常但第二个在我选择下拉选项时返回此错误。
First one is working fine but second one returns this error when I select the dropdown option.
错误:需要本地,预取或远程之一
我试过有远程但我仍然得到错误..我认为代码没有错。任何人都可以帮我解决这些问题吗?
I tried do have remote but I still get the error.. Nothing is wrong in code I believe. Can anyone help me out with the code?
回答这个问题
Answer for this question
如果您收到错误 错误:需要本地,预取或远程之一
即使您提供了本地,预取或远程源..问题不在JavaScript代码中..
If you are getting error Error: one of local, prefetch, or remote is required
even if you have provided local, prefetch or remote source.. The problem is not in JavaScript code..
I通过编辑Input DOM元素修复它。
I fixed it by editing the Input DOM element.
它是< input type =textclass =tw-typeaheadautofocus =自动对焦/>
之前。我将其更改为< input type =textclass =tw-typeahead/>
..
It was <input type="text" class="tw-typeahead" autofocus="autofocus" />
before. I changed it to <input type="text" class="tw-typeahead" />
..
删除自动对焦属性修复了所有错误..很奇怪,但这是问题所在。我和代码争取了2天,但终于找到了它!..
Removing autofocus property fixed all the errors.. Weird but this is the issue. I was fighting with the code for like 2 days but finally found it!..
谢谢,
Rahul Patil
Rahul Patil
推荐答案
如果您收到错误 错误:本地预取之一即使您提供了本地,预取或远程源,也需要远程
..问题不在JavaScript代码中..
If you are getting error Error: one of local, prefetch, or remote is required
even if you have provided local, prefetch or remote source.. The problem is not in JavaScript code..
我通过编辑Input DOM元素修复了它。
I fixed it by editing the Input DOM element.
它是< input type =textclass = tw-typeaheadautofocus =autofocus/>
之前。我将其更改为< input type =textclass =tw-typeahead/>
..
It was <input type="text" class="tw-typeahead" autofocus="autofocus" />
before. I changed it to <input type="text" class="tw-typeahead" />
..
删除自动对焦属性修复了所有错误..很奇怪,但这是问题所在。我和代码争取了2天,但终于找到了它!..
Removing autofocus property fixed all the errors.. Weird but this is the issue. I was fighting with the code for like 2 days but finally found it!..
谢谢,
Rahul帕蒂尔
这篇关于Twitter Typeahead.js,“需要本地,预取或远程之一“即使提供的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!