selectize / selectize.js

Selectize is the hybrid of a textbox and <select> box. It's jQuery based, and it has autocomplete and native-feeling keyboard navigation; useful for tagging, contact lists, etc.
https://selectize.dev/
Apache License 2.0
13.02k stars 3.59k forks source link

Make placeholder from emtpy value <option> #68

Closed danielsokolowski closed 10 years ago

danielsokolowski commented 10 years ago

From my testing selectize.js takes it's placeholder only from the 'placeholder' attribute, for <select> elements the convention is to specify an empty <option> as the placeholder - see: http://dev.w3.org/html5/spec-preview/the-select-element.html

<select name="unittype" required>
 <option value=""> Select unit type </option>
 <option value="1"> Miner </option>
 <option value="2"> Puffer </option>
 <option value="3"> Snipey </option>
 <option value="4"> Max </option>
 <option value="5"> Firebot </option>
</select>

Django and I would assume most frameworks spit out their forms in this format, so how about we use an empty option as placeholder and fall back to the current behaviour of using the placeholder attribute - just as an FYI: the html5 standard only discusses the placeholder attribute for <input> element so it implies to me it's not valid for <select> elements.

selectize-js-empty-option-placeholder-issue

Thoughts?

danielsokolowski commented 10 years ago

Working pull request here https://github.com/brianreavis/selectize.js/pull/69 which results in following rendering of placeholder as defined by empty

selectize js-empty-option-as-placeholder-pull-request

brianreavis commented 10 years ago

Perfect. Thanks for the contribution!