fabianlindfors / multi.js

A user-friendly replacement for select boxes with the multiple attribute enabled
https://fabianlindfors.se/multijs
MIT License
953 stars 76 forks source link

Initialization does not check for limit reached #44

Closed bmcorum closed 3 years ago

bmcorum commented 3 years ago

Initializing multi does not check to see if the number of preselected options matched the passed in limit.

Example:

I am editing an existing record and thus my form loads with the following select HTML

<select id="multi" multiple="multiple">
  <option selected="selected">one</option>
  <option>two</option>
  <option selected="selected">three</option>
  <option>four</option>
</select>

When calling

multi(document.getElementById('multi'), { limit: 2 });

It initializes and I am able to select more than two options. If I select a third and then remove one of my options the limit will be triggered. Looks like the initialize function do not check for limit reached like the toggle_option function does.