Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow for custom-entered choices to be used in the combo box #20

Closed
wants to merge 4 commits into from

Conversation

andrewmunsell
Copy link

While this may not be ideal in all cases, I needed a combo box that allowed for custom text to be input into it.

Original Behavior

Entering custom text into the combo box results in the combo box clearing the new input. This is because the combo box only allows for users to type any of the results already in the original select box.

New Behavior

Entering custom text into the combo box results in the text staying. In addition, this custom value is submitted in the form.

Method

The name from the original select is extracted, and given to the new input field in the combo box. The select's name is then removed. This results in the correct value being submitted in the form. The behavior where the input is cleared if a pre-defined value is not entered (i.e. "Washington" is entered into your demo) is removed as well, to allow for custom text to be entered.

I figure this may be useful for some people, though it may not entirely fit with the goals of this combo box. Alternatively, instead of merging this patch into danielfarrells's combo box, I can maintain a separate repository with these changes for those people that want this functionality.

@andrewmunsell
Copy link
Author

I forgot to mention-- a side effect of this is, the combo box must be initialized before the selected element is set. This is because the default select's values may not have the value that the user entered previously, so a server-side restore of this value isn't necessarily possible. It does work, however, if you set $('input[name=SELECTNAME]').val('Washington'). The side effect is, you can't do that on the select because Washington is not a valid option.

@tarcon
Copy link

tarcon commented Jul 12, 2012

This is important because this behavior is expected from a combobox control.
If this functionality is not provided, it remains a selectbox.

@danielfarrell
Copy link
Owner

I understand that a traditional combobox allows free form entry. That isn't something I have any use case for. This was created to be a typeahead keyboard enabled selectbox. I going to close this. If you want to maintain a fork I'll link to it with a little paragraph explaining why there is a difference.

@recurrence
Copy link

+1! Hopefully this will come up again in the future for inclusion but for now I can make use of the fork. :)

@martenlehmann
Copy link

So, has anyone forked this project to make it a real combobox since then?

I was just looking for a real combobox for bootstrap like many others and found this repo. Unfortunately the project name is totally misleading. It really looks good and it looks like a combobox, but a combobox as defined by all the GUIs in the past decades is a text field that allows for selection of some predefined values as well.

This project on the other hand is 'just' a searchable/autocomplete select box like http://ivaynberg.github.io/select2/

@danielfarrell
Copy link
Owner

Simmer down. It's on the roadmap.

On Wednesday, June 5, 2013, martenlehmann wrote:

So, has anyone forked this project to make it a real combobox since then?

I was just looking for a real combobox for bootstrap like many others and
found this repo. Unfortunately the project name is totally misleading. It
really looks good and it looks like a combobox, but a combobox as defined
by all the GUIs in the past decades is a text field that allows for
selection of some predefined values as well.

This project on the other hand is 'just' a searchable/autocomplete select
box like http://ivaynberg.github.io/select2/


Reply to this email directly or view it on GitHubhttps://github.com//pull/20#issuecomment-19021611
.

@Waschnick
Copy link

Is there any chance this will be implemented as a feature anytime soon?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants