how could I clear a typeahead field in a focusout
event?
The following jQuery code doesn´t seem to work in a typeahead field:
$( "#field" ).focusout(function() {
$(this).val("");
});
how could I clear a typeahead field in a focusout
event?
The following jQuery code doesn´t seem to work in a typeahead field:
$( "#field" ).focusout(function() {
$(this).val("");
});
try with this, example here in fiddle
$('.typeahead').typeahead().bind('typeahead:close', function () {
$('.typeahead').typeahead('val', '');
});
The accepted answer is now out of date. See the latest Typeahead documentation to see that trapping the "close" event and setting the value of the input are different. Here's an equivalent, updated answer:
$('.typeahead').typeahead().bind('typeahead:close', function() {
$('.typeahead').typeahead('val', '');
});
Thanks for all the answers, but the close event did not work for me maybe my setting or something has deprecated. so I have written this code and it worked well.
$('#typeahead-id').typeahead().bind('typeahead:selected', function() {
$('#typeahead-id').typeahead('val', '')
});
© 2022 - 2024 — McMap. All rights reserved.