Typeahead js 不工作,从另一个工作结构复制相同的结构



好吧,我知道这可能是一个有点基本的问题,但是我很累,我还有另外 4 个类型以同样的方式工作得很好,几乎相同的结构,但这个已经死了。

<div id="divconcpingresos">
<div class="input-group-prepend">
<span class="input-group-text" 
id="addon_cp_ingreso">Concepto</span>
</div>
<input id="cp_ingreso" class="typeahead form-control" 
type="text" placeholder="Seleccione un concepto" />
</div>

JS文件只是另外三种工作类型的副本,当然我非常仔细地替换了每个变量(大约4个小时(,我在这里或HTML文件中找不到错误,

var baseconceptosingresos = new Bloodhound({
datumTokenizer: 
Bloodhound.tokenizers.obj.whitespace('Description'),
queryTokenizer: Bloodhound.tokenizers.whitespace,
identify: function (obj) { return 
obj.idconcepto_ingresos; },
remote: {
url: '/api/BuscaConceptoIngreso?id=QUERY',
wildcard: 'QUERY'
}
});
$('#divconcpingresos .typeahead')
.typeahead({
hint: false,
highlight: true,
minLength: 5,
classNames: {
input: 'form-control',
}
},
{
name: 'listaconceptosingresos',
limit: 10,
source: baseconceptosingresos,
display: 'Description'
}
)
.bind("typeahead:selected", function (ev, conceptoseleccionado) {
vmcingreso = conceptoseleccionado.idconcepto_ingresos;
cpi_ok = 1;
console.log(vmcingreso);
})
.bind("typeahead:change", function (e, concepto) {
if (cpi_ok == 1) {
cpi_ok = 0;
}
else {
$("#divconcpingresos .typeahead").typeahead('val', '');
}
});

我的 API 运行良好,这是使用 POSTMAN 的测试

获取 https://localhost:44314/api/BuscaConceptoIngreso?id=marino

[
{
"idconcepto_ingresos": 1,
"idUnidadSAT": 1,
"CodeProdServ": "78101903",
"IdentificationNumber": "0",
"Description": "Transporte marino a carretera (por 
camión) (Transporte con salida marítima y destino a 
carretera (por camión))",
"Price": 600.000000,
"CuentaPredial": "0",
"visible": true
}
]

好的,我找到了问题,今天 Chrome 决定读取我的 js 文件的旧版本,所以从未尝试执行 typeahead 命令。

我的建议:在开发时始终清理互联网缓存。

最新更新