Reputation: 2944
.html
<form:input type="text" id="currentInst" name="instance">
<form:input type="text" id="currentProject" name="project">
AutoComplete.js
function autoFillInstances() {
$("#currentInstance").autocomplete({
autoFocus: true,
source : function(request, response) {
$.ajax({
url : "instances.html",
type : "GET",
data : {
term : request.term
},
dataType : "json",
success : function(data) {
response(data);
},
select: function (request, response) { autoFillProjects(); }
});
}
});
}
function autoFillProjects() {alert("in autocomplete change");}
</script>
Also I tried with onchange event
<script type="text/javascript">
$(document).ready(function() {
$('#currentInst').on('change',
function autoFillProjects() {alert("in autocomplete change");
$("#currentProject").autocomplete({
source : function(request, response) {
$.ajax({
url : "projects.html",
type : "GET",
data : {
term : request.term,
instance: $("#currentInst").val()
},
dataType : "json",
success : function(data) {
response(data);
}
});
}
});
});
});
</script>
If I type something in instance textbox then autocomplete is working for project textbox and it is giving suggestions for project textbox. But If select instance value from suggestions then autocomplete is not working for project textbox. Onchange event is not firing. Please some one help me.
Upvotes: 0
Views: 6603
Reputation: 2944
I changed to 'autocompletechange' event. Now it's working fine.
$('#id').on('autocompletechange',function());
Upvotes: 3