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

Extra Conditions #225

Open
timscott opened this issue May 10, 2013 · 2 comments
Open

Extra Conditions #225

timscott opened this issue May 10, 2013 · 2 comments
Labels

Comments

@timscott
Copy link

How can I add extra conditions?

For example, I'm using the autocomplete to add some child things to a parent thing. I don't want to return things that have already been added because it's not valid to add them twice. I would like place a JS hook that lets me pass an array to the server of the IDs of already added things and then exclude them from the result.

This is a very common use case. I'm pretty sure that the jquery ui supports it, so it would be a matter of exposing it.

Thanks for this great plugin!

@manusajith
Copy link
Member

@timscott is it that you need autocomplete to return unique results ? if so you you could use a scope which returns only distinct items.

@timscott
Copy link
Author

@manusajith No, it's not that I need unique results. Let me try to explain with an example.

Imagine a page where the user chooses which of his friends put into his "special friends" group. Users have lots of friends, so we need autocomplete. The user has just added Sam and Emily to this group, but he has not yet pressed Save. Now he types in the autocomplete to select more friends to add. It would be wrong for our autocomplete results to include Sam and Emily because it is nonsensical to add them twice to the same group.

I have solved this problem before with other autocomplete libraries by passing an array of "ids_to_exclude" as parameter.

To put it more abstractly, we might have transient state on the page that can affect what we want to autocomplete to return, and the way to handle that is to allow passing parameters.

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

No branches or pull requests

3 participants