Skip to content

Recharge after new registration #1815

@ivanteles

Description

@ivanteles

I'm using version 0.9.3 of https://github.com/twitter/typeahead.js/blob/master/doc/jquery_typeahead.md

I have a screen that works perfectly, in the empty template, I add a link that opens a modal to register a new option.

When registering, the user closes the modal, but when making a new call to the field, despite the call to the method, it is occurring correctly and bringing in the existing data and also the new data that has just been registered.

The plugin displays an empty list.

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: [`<div class='empty-message'><a href='${urlAdd}' class="detalhesPaiPai hand" data-original-title='${title}' title='${title}'>Nenhuma informação encontrado, clique aqui e faça o cadastro</a></div>`].join('\n'),
            suggestion: function (data) { return '<p>' + data.nome + '</p>'; }
        }
    }).bind('typeahead:select', function (ev, item) {
        $(campoSetVal).val(item.id);
    });
}
carregarDadosComoAddUrlSetValSelectItem("#NomeCategoria", "/Categoria/AutoComplete", "/Categoria/Add?tipo=add", "Nova categoria", "#IdCategoria");

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions