Typeahead js无法正常工作,从另一个正常工作中复制的相同结构

问题描述 投票:0回答:1

[好吧,我知道这可能是一个基本问题,但是我很累,我还有另外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
     }
    ]
typeahead.js
1个回答
0
投票

[好,我发现了问题,今天Chrome浏览器决定读取我的js文件的旧版本,因此从不尝试执行typeahead命令。

我的建议:开发时始终清理Internet缓存。

© www.soinside.com 2019 - 2024. All rights reserved.