Typeahead clears the input when the value is provided by javascript

2

I'm using the Typeahead version 0.9.3 to auto-complete my inputs. It's working fine, it takes the information from the bank and it shows everything right.

However, if I want to set some value for the input through JavaScript . When the user clicks on the field and then the value of the field is null.

If I put the value in the value property of input . This does not happen. My problem is that I need to assign input value through JavaScript .

$(document).ready(function() {
    $('#teste').typeahead({
        limit: 50,
        minLength: 1,
        remote : '../db/dbAutoComplete.php?&query=%QUERY'
    });

    $('#teste').val('Valor que some se clicar fora do campo');
    //Estou forçando o valor a título de exemplo

});

And my HTML has only input.

input type='text' name='teste' id='teste' value='' required
    
asked by anonymous 25.11.2015 / 14:25

0 answers