Skip to content

Using the sorted widget breaks autocomplete #22

@VascoVisser

Description

@VascoVisser

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions