I'm working with the jqueryUI autocomplete script. The thing is that I want to limit the number of suggestions it provides to 6, as it is offering too much suggestions. This is the script:
$.get('file.txt', function(x) {
var i;
var pos = 0;
var availableTags = [];
x = x.split(/[\#\n]+/);
for (i = 0; i < x.length; i = i + 4)
availableTags[pos++] = x[i];
console.log(availableTags);
$(function() {
$("#search").autocomplete({source: availableTags});
response(availableTags.slice(0, 6));
});
}, 'text');
I spotted and excellent solution by Andrew Whitaker but can't make it work. He suggested to use
response(availableTags.slice(0, 6));
Any solution to limit the number of suggestions on my script?