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

Thanks for selectize!

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.