Search on Click with Jquery's Autocomplete -
i trying simulate youtube autocomplete search experience.
i can't find option when viewer clicks on listed item , automatically proceeded search said item.
my coding follow:
<script type="text/javascript"> var data = ['array1','array2']; $(document).ready(function() { $j("input#directorysearch").autocomplete(data); }); </script>
the above code allow user click on of listed items, however, fill search box rather automatically searching.
i wanted similar behaviour, using jqueryui's default autocomplete widget. trick use 'select' event, submitting select-handler not give desired results, because input not yet have selection filled in.
the following code works me though:
$("input#searchbox").autocomplete({ source: autocomplete, select: function(event, ui) { $("input#searchbox").val(ui.item.value); $("#searchform").submit(); } })
(in example above, 'autocomplete' url points completion source)
where input#searchbox actual input entry, , #searchform parent form. basically, need fill input before submitting yourself.
Comments
Post a Comment