Skip to content

Instantly share code, notes, and snippets.

@keeran
Created August 3, 2010 21:54
Show Gist options
  • Select an option

  • Save keeran/507231 to your computer and use it in GitHub Desktop.

Select an option

Save keeran/507231 to your computer and use it in GitHub Desktop.
$("#SearchForm #name").autocomplete("/customers/search.json",{
minChars: 2,
highlight: false,
delay: 100,
width: 310,
parse: function(data){
var array = new Array();
for (var i=0; i < data.length; i++)
{
array[i] = {data:data[i], value: data[i].first_name, result: data[i].last_name + ", " + data[i].first_name}
}
return array;
},
formatItem: function(item){
return "<a href='/customers/" + item.id + "'>" + item.last_name +", " + item.first_name + "</a>";
}
}).bind("result", function(event, data, value) {
window.location = "/customers/" + data.id;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment