sergiodlopes / jquery-flexdatalist

Flexible input autocomplete/datalist plugin for jQuery
http://projects.sergiodinislopes.pt/flexdatalist/
MIT License
365 stars 84 forks source link

multiple, toggle: Removing items doesn't work correctly when toggled items exist earlier in the selection #242

Open ReformCopyright opened 2 years ago

ReformCopyright commented 2 years ago

Because in multiple.remove, index = $li.index() counts the disabled <li> elements, which are not represented in the _this.value array. We need to look up the value to remove in _this.value or find the correct index with something like $multiple.find('li:not(.input-container):not(.disabled)').index($li).