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 not working when some fields presented #4900

Closed
mayashavin opened this issue May 9, 2017 · 1 comment
Closed

maximumSelectionLength not working when some fields presented #4900

mayashavin opened this issue May 9, 2017 · 1 comment

Comments

@mayashavin
Copy link

Steps to re-produce:

  1. Make a simple multi select drop down
  2. Set maximumSelectionLength to 5 & tokenSeparators to [",", ' ']

Example:
$("select").select2({ data: ["a","b", "c", "d", "e"], multiple: true, maximumSelectionLength: 3, tokenSeparators: [",", ' '], //closeOnSelect: false, width: '100%' })

Expected behavior: should limit the selection to 5.
Actual behavior: no limit.

Investigation: The dataAdapter prototypes get decorated with methods when maximumSelectionLength first, and with tokenSeperators later. Unfortunately, they both have same method name "query", and one will override the other in dataAdapter respectively.

Browsers: Google Chrome
Operating System: Windows/Mac OS

Some of the following fields will override maximumSelectionLength:

  1. query
  2. tokenSeperators
  3. closeOnSelect (set it to false with cause maximumSelectionLength) not working.

Libraries

  • jQuery version:1.11.1
  • Select2 version: 4.0.3

Demo: https://jsfiddle.net/dpnminh/76shLmt2/

@alexweissman
Copy link
Contributor

I'm going to close this as a duplicate of #3514, but your investigation is very helpful. So, I will copy your findings over to that issue.

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

2 participants