aehlke / tag-it

A jQuery UI plugin to handle multi-tag fields as well as tag suggestions/autocomplete.
http://aehlke.github.com/tag-it/
MIT License
2.48k stars 828 forks source link

Pasting Text not interpreted correctly #301

Open EffectivelyEfficient opened 9 years ago

EffectivelyEfficient commented 9 years ago

When you paste tags into the box such as Music, Musical-Instrument it is interpreted as one tag. Pasted text should be checked for commas to allow multiple tags to be pasted at once.

jgimness commented 8 years ago

@Ecroyd Same as issue: #139

Here's a solution that ties into the paste event. I put the code in around line 224, right before the keydown bind.

            this.tagInput.bind('paste', function (event) {
                // Set short timeout so .val() will have a value
                setTimeout(function () {
                    var tagArray = that.tagInput.val().split(/[\n,]+/);
                    if (tagArray.length > 1) {
                        for (var i = 0; i < tagArray.length; i++) {
                            that.createTag(tagArray[i]);
                        }
                    }
                }, 100);
            });