django-autocomplete-light
django-autocomplete-light copied to clipboard
"Django Image Cropping" and "Django Autocomplete Light" are conflicting in the admin interface.
"Django Image Cropping" (IC) and "Django Autocomplete Light" are conflicting in the admin interface. This is a jquery problem.
This is what I think the issue is
- Both use Form Assets (the Media class).
- DAL here
- IC here
- Now keep in mind, that django is keeping the relative order but intersect the assets. See here. I am not sure by what algorithm the order is defined but here is one of the problems. This also means, that the order in which IC and DAL are included in the django settings is not the solution.
- IC and DAL both use jquery and both "patching" jquery with some plugin.
- IC does this in jquery.Jcrop.js.
- DAL does this in here.
Here is the problem
The files are loaded in this order:
image_cropping/js/jquery.Jcrop.min.js
autocomplete_light/jquery.init.js
image_cropping/image_cropping.js
autocomplete_light/jquery.post-setup.js
Why is this a problem?
This is what happens:
-
image_cropping/js/jquery.Jcrop.min.js
is patching jquery -
autocomplete_light/jquery.init.js
is replacing temporary thejQuery
-variable. See here. -
image_cropping/image_cropping.js
is trying to call$(...).Jcrop
which results in an error. - Finally
autocomplete_light/jquery.post-setup.js
is switchingjQuery
back.
Now what can we do?
Maybe we can streamline loading js-files on python-side.
Or we can streamline the execution of js files and do not use and immediately invoked function expression, but execute the code once it is loaded.
I am not sure, but I think replacing the jQuery-variable is no good idea. If we can find a different solution here, I think it would be the most easy fix.
I have also opened an issue over at image cropping some days ago, but I think the issue is on this side.
I'm all for removal jquery.init.js if anybody wants to make a pull request about it.
What about offering an alternative autocomplete implementation in a webcomponent that autoloads and does not depend on jquery ?
https://oss.yourlabs.me/autocomplete-light/ Implemented in #1170
Can we then close this issue ?