I having trouble cause I am fetching some text from the db(mysql), that text is supposed to be filled with the autocomplete but Its retrieved from the db, now when I want to use that text with the autocomplete does not work, I need to take the id(ui.item.id) of the text without using autocomplete, I thinks Its a problem with the event that fires autocomplete (.bind) but I dont know how to fixed, any advise please help? I am stuck
this is my code:
var ids = [];
$(function() {
function split(val) {
return val.split(/,\s*/);
}
function extractLast(term) {
return split(term).pop();
}
$("#txtdestino_Email").bind("keydown", function(event) {
if (event.keyCode === $.ui.keyCode.TAB && $(this).data("autocomplete").menu.active) {
event.preventDefault();
}
}).autocomplete({
source: function(request, response) {
$.getJSON("../../correo/controller/controllerAutocomplete.php", {
term: extractLast(request.term)
}, response);
},
focus: function() {
return false;
},
select: function(event, ui) {
var terms = split(this.value);
terms.pop();
// add the selected item
terms.push(ui.item.value);
// add placeholder to get the comma-and-space at the end
terms.push("");
this.value = terms.join(",");
ids.push(ui.item.id);
return false;
}
});
});
jQuery AutoSuggest by Dew wilson have the following options for selecting values
‘selectedItemProp’ and ‘selectedValuesProp’ in which the selectedValuesProp is used to select the values, for example for a name value collection, this option is used for values and the other selectedItemProp is used for names. ‘asHtmlID’ option helps to set HTML ID of the element. Finally the pluggin renders a hidden field with ID as_values_’CUSTOM_ID’ which holds the values selected where ‘CUSTOM_ID’ is the ID set to ‘asHtmlID’ option