I would 开发者_运维百科like to build a combo box in Rails 3. It's a mix of input textfield and a dropdown menu.
What would be the best way to proceed?
There is no standard implementation of a combobox in html.
Either you provide a simple drop-down box, and add a +
button allowing to dynamically add new items to the list (javascript). This is not bad if the number of items does not change too often.
An often used alternative is to use a standard text-field, and use an autocompleter to suggest the possible options, but allow to user to deviate.
Or you google for the numerous examples of fake combobox (e.g. editable drop-down-box) implementations using javascript.
Write a plugin yourself following whatever you can find at http://jqueryui.com/demos/autocomplete/#combobox
精彩评论