JQuery Autocomplete without using label, value, id -


is possible have jquery autocomplete work without using conventional id,label,value?

for instance, not wish use:

[ { "id": "botaurus stellaris", "label": "great bittern", "value": "great bittern" }, { "id": "asio flammeus", "label": "short-eared owl", "value": "short-eared owl" }] 

but rather:

[ { "my_id": "botaurus stellaris", "first_name": "great bittern", "last_name": "great bittern" }, { "my_id": "asio flammeus", "first_name": "short-eared owl", "last_name": "short-eared owl" }] 

so like, jquery autocomplete takes id,value,label, can make take my_id, first_name, last_name , make jquery autocomplete treat same id,label,value?

this might useful, when don't wish modify data's keys coming datasource, display on jquery autocomplete.

never mind,

found answer jqueryui's autocomplete example source:

 $( "#city" ).autocomplete({ source: function( request, response ) { $.ajax({ url: "http://ws.geonames.org/searchjson", datatype: "jsonp", data: { featureclass: "p", style: "full", maxrows: 12, name_startswith: request.term }, success: function( data ) { response( $.map( data.geonames, function( item ) { return { label: item.name + (item.adminname1 ? ", " + item.adminname1 : "") + ", " + item.countryname, value: item.name } })); } }); }, minlength: 2 }); 

here, source been assigned function, can convert , return type of keys required converted jquery's autocomplete's id,value,label.

may helps some.


Comments