V
V
Valeriy19972015-09-09 11:33:00
JavaScript
Valeriy1997, 2015-09-09 11:33:00

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;
      
        }
    })
})


full code: jsfiddle.net/t52ka/74

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Pavel, 2015-09-09
@Valeriy1997

jsfiddle.net/t52ka/76

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question