brianreavis/selectize.js — pull request #355 by disruptek (2014-03-29 01:26:33+00:00)
Title: issue removeItem() before addItem() iff maxItems=1

[ Take two. Everything works but my brain. ]

I noticed that when maxItems=1 only item_add events are emitted, which doesn't play well with other objects trying to monitor selectize. This change causes any selected items to get removed (with all that entails) in addItem() before new items are selected.

I used a loop to handle the (unlikely) case in which multiple items are currently selected and the settings are changed programmatically.

Tests pass.