Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recharge after new registration #1815

Open
ivanteles opened this issue Sep 15, 2023 · 1 comment
Open

Recharge after new registration #1815

ivanteles opened this issue Sep 15, 2023 · 1 comment

Comments

@ivanteles
Copy link

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");
@ivanteles
Copy link
Author

Any personal tips?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

1 participant