新登记后再充电

作者: ivanteles创建于 2023年9月15日更新于 2023年9月28日
var carregarDadosComoAddUrlSetValSelectItem = function (campo, url, urlAdd, title, campoSetVal) { const dados = new Bloodhound({ datumTokenizer: Bloodhound.tokenizers.whitespace, queryTokenizer: Bloodhound.tokenizers.whitespace, sufficient: 1, indexRemote: true, remote: { wildcard: '%QUERY', url: url + '?q=%QUERY' } }); dados.initialize(); $(campo).typeahead({ hint: true, highlight: true, minLength: 1 }, { display: 'nome', source: dados, templates: { empty: [``].join('\n'), suggestion: function (data) { return '

' + data.nome + '

'; } } }).bind('typeahead:select', function (ev, item) { $(campoSetVal).val(item.id); }); } carregarDadosComoAddUrlSetValSelectItem("#NomeCategoria", "/Categoria/AutoComplete", "/Categoria/Add?tipo=add", "Nova categoria", "#IdCategoria");

内容来源: twitter/typeahead.js