yourlabs / django-autocomplete-light

A fresh approach to autocomplete implementations, specially for Django. Status: v4 alpha, v3 stable, v2 & v1 deprecated.
https://django-autocomplete-light.readthedocs.io
MIT License
1.79k stars 467 forks source link

select2 conflicts with (auto)-select2 #866

Open Paul424 opened 7 years ago

Paul424 commented 7 years ago

I've been debugging why my select2 autocomplete-light controls stopped working, they are select2 initialized controls but no remote call is made to load options and only an empty dropdown is shown when i open it.

It appears that this is because the select2 control is initialized first by autocomplete.init.js and then reinitialized as a regular select2 control; without the ajax options.

This happens because i obviously need to serve many pages on the website and only some are autocomplete fields, so i packages select2.js in my own js/lib and basically all $("select") items are initialzed...

My question is what the best practice is to combine the two?

Paul

Paul424 commented 7 years ago

For now i fixed it by making the selector more strict: $("select:not([data-autocomplete-light-function])")

jpic commented 7 years ago

Nice, sounds like a change worth contributing !