Skip to content
This repository has been archived by the owner on Oct 2, 2019. It is now read-only.

Comma (,) token included model #757

Open
sime opened this issue Mar 13, 2015 · 7 comments
Open

Comma (,) token included model #757

sime opened this issue Mar 13, 2015 · 7 comments

Comments

@sime
Copy link
Contributor

sime commented Mar 13, 2015

When using a comma (,) as a tagging token, the comma remains appended to the model. Ideally the token should be removed from the model.

http://plnkr.co/edit/NbNTG9yR7PJquhtIJdJU?p=preview

screen shot 2015-03-13 at 16 49 59

@dmitryevseev
Copy link

+1

@cyrilf
Copy link

cyrilf commented May 13, 2015

👍 that's the behavior I was expecting too

@cyrilf
Copy link

cyrilf commented May 13, 2015

Just for your information, I figure out that adding the attribute tagging-label="" to your ui-select directive will solve this bug. See this Plnkr
I specified an empty string as I don't want any value to be displayed, but as in the Plunkr, you can specify one.

Hope it helps!

(Still a bug thought!)

@sime
Copy link
Contributor Author

sime commented May 27, 2015

The workaround is valid, though you need the following CSS to mimic the desired functionality.

.ui-select-choices {
  display: none;
}

@roko-p
Copy link

roko-p commented Oct 22, 2015

Yeah, so when you have the tagging-label="false" (when you don't want items appearing in the dropdown), you get the comma appended to the model.

One workaround is the css hack that @sime suggested above, another one is to set tagging=tagTransform where

$scope.tagTransform = function (newTag) {
        // remove the comma at the end if it exists
        if(newTag[newTag.length - 1] === ',') {
            newTag = newTag.slice(0, -1);
        }
        return newTag;
    };

...both ugly!

+1!

@roko-p
Copy link

roko-p commented Oct 22, 2015

I ended up creating this directive to completely hide the choices dropdown, I use it instead of tagging-label="false" where I'm OK with hiding the whole dropdown (so I just put my-hide-choices-dropdown where tagging-label="false" would go)

angular.module('myApp')
    .directive('myHideChoicesDropdown', function() {
        return {
            link: function(scope, element) {
                element.find('.ui-select-choices').hide();
            }
        };
    });

Thanks @sime !

@cesar-oyarzun-m
Copy link

hey @roko-p I try your solution and also the solution with css but both give me erros, here is the error

TypeError: Cannot assign to read only property '_uiSelectChoiceDisabled' of label undefined

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

No branches or pull requests

6 participants