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

Using the sorted widget breaks autocomplete #22

Open
VascoVisser opened this issue Oct 29, 2024 · 0 comments
Open

Using the sorted widget breaks autocomplete #22

VascoVisser opened this issue Oct 29, 2024 · 0 comments

Comments

@VascoVisser
Copy link

VascoVisser commented Oct 29, 2024

When using the SortedFilteredSelectMultiple widget other fields on the same admin page that use autocomplete (i.e., fields designated with the ModelAdmin.autocomplete_fields attribute) break.

It might be that the jquery instance used in admin/js/autocomplete.js is somehow swapped out with one that does not have the required functionality. Specifically the error message in the browser console is:

autocomplete.js:7 Uncaught TypeError: $(...).select2 is not a function
    at HTMLSelectElement.<anonymous> (autocomplete.js:7:24)
    at Function.each (jquery.min.js:16:11390)
    at $.fn.djangoAdminSelect2 (autocomplete.js:6:11)
    at HTMLDocument.<anonymous> (autocomplete.js:27:60)
    at Object.resolveWith (jquery.min.js:16:14211)
    at Function.ready (jquery.min.js:16:9196)
    at HTMLDocument.y (jquery.min.js:16:13679)

The autocomplete fields work fine when not using SortedFilteredSelectMultiple. I suspect it has something todo with the order in which the javascript dependencies are included. But I'm unsure how to go about changing the order.

Any pointers on how to fix this issue are appreciated.

Versions:
Django 4.2.13
django-sortedm2m-filter-horizontal-widget 2.0.1

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

No branches or pull requests

1 participant