django-autocomplete-light icon indicating copy to clipboard operation
django-autocomplete-light copied to clipboard

"Django Image Cropping" and "Django Autocomplete Light" are conflicting in the admin interface.

Open mogoh opened this issue 5 years ago • 3 comments

"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.

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:

  1. image_cropping/js/jquery.Jcrop.min.js is patching jquery
  2. autocomplete_light/jquery.init.js is replacing temporary the jQuery-variable. See here.
  3. image_cropping/image_cropping.js is trying to call $(...).Jcrop which results in an error.
  4. Finally autocomplete_light/jquery.post-setup.js is switching jQuery back.

Bildschirmfoto von 2020-01-10 16-53-45

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.

mogoh avatar Jan 10 '20 16:01 mogoh

I have also opened an issue over at image cropping some days ago, but I think the issue is on this side.

mogoh avatar Jan 10 '20 16:01 mogoh

I'm all for removal jquery.init.js if anybody wants to make a pull request about it.

jpic avatar Mar 18 '20 20:03 jpic

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 ?

jpic avatar Jul 22 '20 02:07 jpic