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 more than one autocomplete field. #5

Closed
wants to merge 10 commits into from

Conversation

havocbane
Copy link

  • Use a form prefix to make name and ID unique.
  • Version bump to 0.1.5 (0.1.4 was static files change for Django 3.0)

havocbane and others added 8 commits March 24, 2020 16:58
* Django dropped 'staticfiles' in templates. Use 'static' instead.
… multiple autocomplete filters can be put on the page. Without this, all fields are named/IDed autocomplete_field and there's a collision.
Update version to acknowledge change
By specifying a prefix of the field's name on each Autocomplete form multiple autocomplete filters can be put on the page. Without this, all fields are named/IDed autocomplete_field and there's a collision.
… "endswith" jQuery selector, without that the field isn't found and a Javascript console error fires.
The field being named with the field name means we should be doing an "endswith" jQuery selector, without that the field isn't found and a Javascript console error fires.
I put the dollarsign in the wrong place. It should go on the field, n…
@vigo
Copy link
Collaborator

vigo commented Apr 18, 2020

Hi @havocbane , I did not understand, "more than one autocomplete field" situation? It's already more than one field?

autocomplete_list_filter = ('category', 'author', 'tags')

You have 3 different fields and widgets... Can you explain more if possible?

@havocbane
Copy link
Author

havocbane commented Apr 20, 2020

@vigo thank you for your feedback; let me elaborate.

We were seeing an issue where multiple fields would render with default Django form drop-downs instead of auto-complete (the last one in the list filter would always be an auto-complete).

We were able to address this by adding the form prefix when instantiating the autocomplete form so that the elements would have unique names/IDs in the HTML.

If this has not been your experience, it is certainly possible that things have changed in later Django versions. We have been using 3.0.5 (indeed, this pull request includes Django updates as well, e.g. static module loading).

@vigo
Copy link
Collaborator

vigo commented Apr 23, 2020

@havocbane with all due respect, can you please share code snippet? I'd like to produce this issue locally and try to understand better.

@havocbane
Copy link
Author

@havocbane with all due respect, can you please share code snippet? I'd like to produce this issue locally and try to understand better.

Sure, I will try to get you a simple example to reproduce the issue next week.

@vigo
Copy link
Collaborator

vigo commented Aug 17, 2021

Thanks @havocbane , I've picked JavaScript changes manually, others were fixed via @guglielmo 's PR...

@vigo vigo closed this Aug 17, 2021
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.

4 participants