I am using jquery autocomplete with a json datasource.
This is my code: clientId, clientName are the id's of the input fields.
$("#clientId").autocomplete({
source: function(request, response){
var clientId=request.term;
$.ajax({
type:"GET",
url:"getClients.htm?ClientId=" + clientId +"&ClientName=",
dataType:"json",
success: function(data){
if(pageCountClientId == 0){
data.push({clientId:"More Options",clientName:"More Options"});
pageCountClientId++;
}
else{
data.push({clientId:"Previous Options",clientName:"Previous Options"});
pageCountClientId++;
}
response($.map(data,function(value,key){
return{
label:value.clientId,
value:value.clientName
};
}));
}
});
},
minLength: 1,
select: function(event, ui){
if(ui.item.value == "More Options"){
pageCountClientId++;
}
else if(ui.item.value == "Previous Options"){
pageCountClientId--;
}
else{
$("#clientName").val(ui.item.value);
$("#clientId").val(ui.item.label);
$("#clientName").attr("disabled", "disabled");
$("#clientId").attr("disabled", "disabled");
}
return false;
},
});
So now when the user clicks on the 'More Options' value, in the select event I want to get the next set of results and display it in the dropdown which appears. How to make it happen. any pointers in the right direction will be appreciated.