I'm using the jQueryUI autocomplete()
function and I can't figure out how to have my form submit when an item is selected.
I think the issue is with the select: event
but I'm new with jQueryUI and can't figure out how to make this work.
Here's my code which works fine otherwise:
<script type="text/javascript">
$(document).ready(function() {
$(function() {
$( "#search_box" ).autocomplete({
source: function(request, response) {
$.ajax({ url: "<?php echo site_url('autocomplete/suggestions'); ?>",
data: { term: $("#search_box").val()},
dataType: "json",
type: "POST",
success: function(data){
response(data);
},
select: function (event, ui) {
$(event.target).val(ui.item);
$('#search_form').submit();
return false;
}
});
},
minLength: 1
});
});
});
</script>
Any assistance would be greatly appreciated!