Skip to content

Instantly share code, notes, and snippets.

@djtfmartin
Last active August 28, 2015 08:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save djtfmartin/13d16691160d8018b55a to your computer and use it in GitHub Desktop.
Save djtfmartin/13d16691160d8018b55a to your computer and use it in GitHub Desktop.
species-autocomplete.js
// initialise plugins
$(function(){
var autocompleteUrl = 'http://species-ws.als.scot/auto';
// autocomplete on navbar search input
$("input.general-search").autocomplete(autocompleteUrl, {
extraParams: {limit: 100},
dataType: 'json',
parse: function(data) {
var rows = new Array();
data = data.autoCompleteList;
for(var i=0; i<data.length; i++) {
rows[i] = {
data:data[i],
value: data[i].matchedNames[0],
result: data[i].matchedNames[0]
};
}
return rows;
},
matchSubset: false,
formatItem: function(row, i, n) {
return row.matchedNames[0];
},
cacheLength: 10,
minChars: 3,
scroll: false,
max: 10,
selectFirst: false
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment