Skip to content

autocomplete remove item after selected, add item after removed #162

@pete111

Description

@pete111

I use jquery tagEditor plugin with autocomplete.
My code:

        var pLangs = ['ActionScript', 'AppleScript', 'Asp', 'BASIC', 'C', 'C++', 'CSS', 'Clojure', 'COBOL', 'ColdFusion', 'Erlang', 'Fortran', 'Groovy', 'Haskell', 'HTML', 'Java', 'JavaScript', 'Lisp', 'Perl', 'PHP', 'Python', 'Ruby', 'Scala', 'Scheme'];
        $('#demo2').tagEditor({
            autocomplete: { 
                minLength: 0, 
                delay: 0, 
                position: { collision: 'flip' }, 
                source: pLangs,//['ActionScript', 'AppleScript', 'Asp', 'BASIC', 'C', 'C++', 'CSS', 'Clojure', 'COBOL', 'ColdFusion', 'Erlang', 'Fortran', 'Groovy', 'Haskell', 'HTML', 'Java', 'JavaScript', 'Lisp', 'Perl', 'PHP', 'Python', 'Ruby', 'Scala', 'Scheme'], 
                create: function (event, ui) {
                    // open dialog on click
                    $(this).autocomplete("search", "");
                    //alert('cau');  
                }
            },
           beforeTagDelete: function(field, editor, tags, val) {
                v.splice($.inArray(val, pLangs), 1);
                alert(cCities);
                alert(val);
            },
            beforeTagSave: function(field, editor, tags, tag, val) {
                alert(val);
            },
            removeDuplicates: true,
            forceLowercase: false,
            delimiter: ", ",
            placeholder: 'Programming languages heeere...'
            
        });

I am trying to hide autocomplete item from shown list when this item is selected - my idea is to remove it from pLang variable so next autocomplete will not show it in list. And reverse, if I click on (x) of this item in inputbox (to remove it from input), this item should be added back to pLang in next autocomplete list to show.

how should I edit my code please?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions