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

maximumSelectionLength issue with tokenSeparators on created tags #4500

Closed
akoury opened this issue Jul 24, 2016 · 5 comments
Closed

maximumSelectionLength issue with tokenSeparators on created tags #4500

akoury opened this issue Jul 24, 2016 · 5 comments

Comments

@akoury
Copy link

akoury commented Jul 24, 2016

maximumSelectionLength is being ignored when i use the tags: true option, i can create as many tags as a i want while separating them through the characters i specified in the tokenSeparators, therefore it ignores the limit.

@kevin-brown
Copy link
Member

This is a bug, and I thought there was already a ticket about it. But I can't find one, so this will remain open until it's fixed, or until the duplicate comes up.

@devzl
Copy link

devzl commented Oct 12, 2016

Any fix for this yet?

My workaround if anyone need it is to check $('.select2-selection__choice').length before returning a tag in createTag

@magnum-ferox
Copy link

Hello! I overwrite tokenizer function for paste from clipboard.
But select2 (multiple) ignore maximumSelectionLength directive.

I can acces to this value in overwrited tokenizer via this.maximumSelectionLength
But I cannot access to count of current selected values.

Could you tell me how to do it?

@magnum-ferox
Copy link

A lot of hurts, but it works =)

cnt = null; this.current(function (selected) { cnt = selected.length; });
if( this.maximumSelectionLength < cnt ) {
// 'You can only select ' + self.maximumSelectionLength + ' item'
}

@alexweissman
Copy link
Contributor

Closing this as a duplicate of #3514.

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

No branches or pull requests

5 participants