Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support for pasting a list of items #14

Open
mmezzacca opened this issue Jun 14, 2011 · 4 comments
Open

Support for pasting a list of items #14

mmezzacca opened this issue Jun 14, 2011 · 4 comments

Comments

@mmezzacca
Copy link

When typing a new tag the comma automatically performs the same function as hitting enter (creates a new tag). When pasting (Ctrl+V) a list of comma separated words/tags (eg. tennis, baseball, hockey, sports) the functionality is lost. Hitting comma or enter after pasting will cause the whole string to become one large tag "tennis, baseball, hockey, sports" instead of automatically splitting them up.

Probably a feature request more than an issue.

@webworka
Copy link
Owner

Hi,

is this already working in your branch?

@mmezzacca
Copy link
Author

no...

@garjitech
Copy link
Contributor

Take a look at my fork where I've provided a custom parsing function which can be used to split the comma separated words/tags.
https://raw.github.com/garjitech/Tagedit/master/playground.html
https://raw.github.com/garjitech/Tagedit/master/js/jquery.tagedit-1.2.0.js

@mmezzacca
Copy link
Author

@garjitech - Thanks that seems to work. A couple things.

  1. When using autoComplete, if a value has a comma in it (eg. "Common, Quail"), the parsing will split it into two different entries (Common | Quail) and with the same name (eg. tag[2-a]).

  2. I added $.trim() to ensure whitespace isn't an issue when pasting a list that maybe comman space seperated
    (eg. tennis, baseball, football).

Here's the simple comma parsing code (the email parsing removed) which handles pasting a list:

        parseValues: function(values) {
            var parsedVals = [];
            var splitVals = values.split(',');
            for(var i=0; i<splitVals.length; i++){
                var value = $.trim(splitVals[i]);
                parsedVals.push({ 
                    id:'', 
                    label:value, 
                    value:value
                });
            }
            return parsedVals;
        }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants