In this post I used jQuery to autocomplete an input box with results from CRM 2011. I wanted to give the number of results returned for the particular autocomplete query. I chose to use the autocomplete open: parameter to get the number of results returned, and I put that result in a div with an ID of “Count”
open: function(event,ui){ var len = $(this).autocomplete("widget").find( "li" ).length; var resultText='RESULTS'; if (len==1) resultText='RESULT' $('#Count').text('FOUND '+len+' '+resultText); }, close: function(event,ui){ $('#Count').text('ENTERPRISE SEARCH'); }
Very useful many thanks – I incorporated as follows:
$( “#tags” ).autocomplete({
source: function( request, response ) {
var matcher = new RegExp( “^” + $.ui.autocomplete.escapeRegex( request.term ), “i” );
response( $.grep( arVs, function( item ){
return matcher.test( item );
}) );
// display size of autosuggest list
var tags = “List size: “+$(“#tags”).autocomplete(“widget”).find( “li” ).length;
$(“#Count”).text(tags);
}
});