Form submit after Autocomplete failing
Hi,
I have successfully attached the JQuery Autocomplete to my HTML form. The issue I am having though is that in the "success:" callback I call $('#findterm_form').submit(), which fails to submit the form. I added an onsubmit handler which calls alert, so the event is firing, but for some reason the form will not submit.
I have trawled various forums regarding this issue, and I cannot forgure out why this is not working for me. Javascript (JQuery) code is below:
$(document).ready(function(){
$("#term").autocomplete({
source: function( request, response ) {
$.ajax({
url: "http://intranet/knowledge-tree/Default/glossarysearch",
dataType: "json",
data: {
style: "full",
maxRows: 12,
tag: request.term,
view: "json"
},
success: function( data ) {
response( $.map( data.words, function( item ) {
return {label: item,value: item}
}));
}
});
},
minLength: 2,
select: function( event, ui ) {
$("#term").val(ui.item.value);
$('#findterm_form').submit();
}
});
$('#findterm_form').submit(function(){
//alert('submit called');
return true;
});
});
HTML form is below. Note the website is locally hosted, hence the odd-looking action attribute:
<form method="post" action="/knowledge-tree/Default/glossary" id="findterm_form">
<input class="text" style="width:300px; font-size: 0.8em" type="text" id="term" name="term"/>
<input type="submit" class="button clear_left" id="submit" value="Search"/>
</form>
Thanks.