Answer the question
In order to leave comments, you need to log in
How to add an attribute when context is generated in autocomplete?
I'm using the autocomplect plugin for autocompletion. I need to add the data-context-key attribute (the value of the attribute key of a specific element) when forming the context (add this attribute to each generated tag). But I don't know how to implement it ... Tell me, who has already done this autocomplect ?
My code :
$(function(){
$( "#myinput" ).autocomplete({
minLength: 0,
source: function(request, response) {
var term = $.trim(request.term);
var reg = new RegExp($.ui.autocomplete.escapeRegex(term), "i");
if (term !== "") {
response($.grep(getbigData(), function(tag) {
return tag.match(reg);
}));
}
},
focus: function( event, ui ) {
$( "#myinput" ).val( ui.item.value);
return false;
},
select: function( event, ui ) {
$( "#myinput" ).val( ui.item.value);
return false;
}
})
})
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question