- add another class to select2, allowing it to be used as autocomplete text field #494

Closed
wants to merge 1 commit into
from

Conversation

Projects
None yet
3 participants

Evan-R commented Oct 13, 2012

  • allows select2 to be used for as auto-complete for an input form
  • just use pass "select2Class: 'input'" as a param object property
@Evan-R Evan-R - add "input" class to select 2 (essentially use as autocomplete)
- allows select2 to be used for as auto-complete for an input form
- just use pass "select2Class: 'input'" as a param object property
49c62db
Contributor

ivaynberg commented Oct 13, 2012

your patch is against 3.2 instead of master, so its really hard to read and cannot be merged....

Evan-R commented Oct 14, 2012

Thanks for the reply Igor - have you tried the code? If you are interested in using it, I'd be happy to implement the new functionality on the master copy.

Cheers,

this sounds very useful! +1 to @Evan-R and would be happy to lend a hand.

Contributor

ivaynberg commented Oct 17, 2012

can you guys create a jsfiddle so i can take a look. very limited on time unfortunately right now

Evan-R commented Oct 18, 2012

Hey @ivaynberg I just put up a jsfiddle. Right now it submits the form on select or enter, but I guess we could allow a function to be passed there instead. Anyway, please take a look:

http://jsfiddle.net/sWJHC/1/

@leoromanovsky if you are interested in helping out, and Igor wants to use it in a future release of the project, I'll merge this over to the current master copy, and maybe we can discuss some ways of improving it, such as my suggestions, but perhaps other as well :)

Contributor

ivaynberg commented Oct 18, 2012

how is this different then a single select with createSearchChoice that returns the input (like in the tags)?

Evan-R commented Oct 18, 2012

*edit - scratch the first part, this is not the case *

On "enter" (I guess I should also add different "tab" behaviour), the "input" class select2 simply uses the current value that the user has typed without needing to select the custom choice from the list

Actually, I suppose this is more or less way too large of an update now to justify inclusion. Sorry about that.

Contributor

ivaynberg commented Oct 18, 2012

i think a better way to do this would be how multiselect works. you have the actual input field you are typing into right away - not in the dropdown

Evan-R commented Oct 18, 2012

Thanks Igor - I will take a look into that, that may indeed be a better way. The reason that I came up with this methodology originally to address my needs was because I did not want the custom selection box showing up, and "enter" was needing to wait for the ajax request to populate the suggestions field, so response times were often laggy. Is there a way to make the "custom suggestion" show up before the ajax fetched suggestions?

Contributor

ivaynberg commented Feb 9, 2013

i think this can all be accomplished by using a combination of createSearchChoice, maxSelectionSize:1, and selectBlur: true options in combination with a multiselect box.

ivaynberg closed this Feb 9, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment