I am having a right manic day trying to figure out how to post the key not the value of a input field.
Jquery
jQuery( document ).ready(function() {
jQuery("#autocomplete").autocomplete({
source: function (request, response) {
jQuery.ajax({
url: "{{URL('/autocomplete')}}",
data: {
autocomplete: this.term
},
success: function (data) {
console.log(data[0]['label']);
response( jQuery.map( data, function( item ) {
return {
label: item.label,
value: item.id
};
}));
},
//This does not get picked up?
select: function(event, ui){
alert('this is not firing on select?');
jQuery('#hidden').val(ui.item.value);
}
});
},
});
I have updated code, still i cant get the key pushed to the hidden field on select.
Live Preview ( type Stoke in location search ) http://isca01.bigwavemedia.info/~hospita2/crawler/public/index.php/search