I'm trying to have a jQuery autocomplete. I have specified some data but when I select an item on the drop down, it always pushes the value into the meta-area elements. I want the label. How to do this? Trying to get it to show the label in #meta-area rather than the value.
HTML:
...
area:<input type='text' size='20' id='meta-area' />
<input type='hidden' id='meta_search_ids' value='' />
...
JavaScript:
$(document).ready(function(){
var data =[
{'label':'Core','value':1},
{'label':' Selectors','value':2},
{'label':'Events' ,'value':3}];
$("#meta-area").autocomplete({source:data,
select: function(e, ui) {
$("#meta_search_ids").val(ui.item.value);
// this part is not working
//$(this).val(ui.item.label);
$('#meta-area').text('this is what I want');
}
});
//alert("this loaded");
});