oakmac / autocompletejs

AutoCompleteJS Widget
Other
72 stars 14 forks source link

Question about AutoCompleteJS #82

Closed MajorKusinagi closed 10 years ago

MajorKusinagi commented 10 years ago

Hello again!

Been using your plug-in, it works great and has been well received by our end users so thank you very much for creating it.

However we came across a situation that I would like your advice on...

In all of your examples you start with the basic (Banana, Apples, Oranges) list of items. Say you pick "Apples", it adds an "Apples" token...great. Then you can rinse and repeat by picking one of the options again.

For our application, we are using the autocomplete plug-in with a list of employees. So if I pick myself from a possible list of options, it would be nice if when I went to add the next token, I was no longer available as a choice since I have already been picked once.

Is there an option currently that makes this possible? I don't think I saw one, and just wanted to know if I was missing it. If there is not one, how would you recommend I go about implementing this? I'd appreciate any suggestions.

Thanks, MK

oakmac commented 10 years ago

Thanks for the kind words; I appreciate it :)

This issue is what you want: "use once" options

It's not been implemented yet because I'm not sure it's possible to do correctly without bugs. The crux of the problem is that I allow dynamic changing of lists, options, and tokens after the widget has been instantiated (ie: setList, removeList, setValue, etc)

You should be able to accomplish what you want with a smart combination of setList and onChange. You'll have to keep track of what options the user has selected and remove them from your "employees" list (conversely, you'll need to add the option back if the user removes an "employee token").

MajorKusinagi commented 10 years ago

I'll give that a try, thanks again!