Reputation: 1005
I would like to auto submit a form when a value from the autocomplete input text is selected.
I'm actually trying something like this but it auto submit each time the text is filled.
$('input.text').on('keyup', function() {
$('form').submit();
});
Thanks
Upvotes: 0
Views: 1345
Reputation: 1744
You can use below code from http://api.jqueryui.com/autocomplete/#event-select :
$("#searchField").autocomplete({
source: "values.json",
minLength: 2,
select: function(event, ui) {
$("#searchField").val(ui.item.value);
$("#form").submit(); }
});
Upvotes: 1