Clear type field

how can i clear the typeahead field in an event focusout

?

The following jQuery code doesn't work on the typeahead field:

$( "#field" ).focusout(function() {
    $(this).val("");
});

      

+3


source to share


2 answers


try with this for example here in the fiddle



$('.typeahead').typeahead().bind('typeahead:closed', function () {
    $(this).val("");
});

      

+2


source


The accepted answer is now out of date. See the latest Typeahead documentation to see that capturing the "close" event and setting the input value are different. Here's an equivalent, updated answer:



$('.typeahead').typeahead().bind('typeahead:close', function() {
    $('.typeahead').typeahead('val', '');
});

      

+1


source







All Articles