Having looked at the JQuery UI autocomplete (v1.8.5) and realized that there was a lack of documentation on sending additional parameters and capturing additional data to autocomplete other fields. I have work, but seriously, it seems like such a hack ... Any thoughts on how to improve this?
<script type="text/javascript">
var optofirst = {
width: 375,
source: function( request, response ) {
var cat = $(this);
var callid = cat[0].element.context.id;
$.ajax({
url: "automagic.php",
dataType: "json",
data: {
term : request.term,
grab : callid,
},
success: function( data ) {
response( $.map( data, function( item ) {
return {
label: item.first,
value: item.first,
last: item.last,
}
}));
}
});
},
select: function( event, ui ) {
console.log( ui.item ?
"Selected: " + ui.item.last :
"Nothing selected, input was " + this.value);
$("#flyover #lname").attr("value",ui.item.last);
},
minLength: 2,
};
$("#flyover #fname").autocomplete(optofirst);
</script>
source
share