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

mezzanine 4.1 + autocomplete 2.3 + filer 1.1 #736

Closed
frague59 opened this issue Feb 12, 2016 · 21 comments
Closed

mezzanine 4.1 + autocomplete 2.3 + filer 1.1 #736

frague59 opened this issue Feb 12, 2016 · 21 comments
Milestone

Comments

@frague59
Copy link

Hi,
I'm facing a jQuery hell with mezzanine + autocomplete-light.

The constatations :

  • I'm in a mezzanine admin change view, which has
    • an autocomplete field
    • a filer (image) field
  • The mezzanine left menu shows quickly, then it hides imself : is created, but I'm not able to view it.
  • The autocomplete field doen't not work : the actual value is shown, but I can't change it.
  • The filer works perfectly... but I'm pretty sure it has taken the jquery namespace for himself...

TypeError: $ is undefined

If I load a jQ before the autocomplete_light/static.html I have another error :
TypeError: $(...).yourlabsWidget is not a function

I've tracked the jQ versions used, and autocomplete is loaded in a version on jQ, but launched (through $(document).ready()) through the filer version of jQ, the one from filer.
I've tried to noConflict the jQ before autocomplete loadings, but for none..

Could you help me with this issue ? Thanks for your help !

How can I

@frague59
Copy link
Author

Hi,

I've some improvements about this issue :

  • I've moved the autocomplete initialization to the bottom of the page, and it work now, but I do not have the left menu.
  • The left menu still does not shows. If I disable the filer field in the change or create form, the left menu works : the problem really comes from filer.

So I'm still stuck.

Has anybody the same issue ? How can I fix it ? Thanks !

@stefanfoulis
Copy link
Contributor

I personally have no experience with mezzanine. But I suspect this will be a problem with any other widget on the same admin form that uses jQuery.
It probably has to do with the visual updates done for 1.0 on django-filer. We used to avoid using jQuery in the filer widget completely (precisely out of this reason). But it might have been added as part of the visual updates.

@Flight do you know more?

@stefanfoulis
Copy link
Contributor

@frague59 we've been working on fixing a bunch of bugs related to the js loaded by the widget. Could you test with the develop branch to see if this issue was already resolved for you?
(/cc @lory87 )

@stefanfoulis
Copy link
Contributor

@frague59 would be cool if you could confirm if our latest changes fix the issue. :-)

@stefanfoulis stefanfoulis removed this from the 1.2.0 milestone Mar 2, 2016
@lory87 lory87 removed their assignment Mar 7, 2016
@frague59
Copy link
Author

Hi,
I'did just saw your message, and did update to django-filer to 1.2:

$ pip install django-filer -U

I have the same issue. Could I help you ? How ?
Thanks !

@frague59
Copy link
Author

... I've tryed with the development branch of django-filer, and it seems to work for me : I can see the left menu and the autocomplete widget.

I had to re-import jQuery to load autocomplete, but it works now !

The filer itself does not work at all, with no JS error. The widget displays the loaded (previously) image and a text field containing an ID.

Thanks for your help and excuse me for my slow responses.

Bye !

@stefanfoulis
Copy link
Contributor

@frague59 thanks for testing.
Did this work with older versions of django-filer?
Maybe re-loading jquery kills the jquery stuff that the django-filer widget does. That is probably why the filer widget does not initialise.

@frague59
Copy link
Author

@stefanfoulis

hi,

It worked with django-filer==1.1.1, the widget was showed, autocomplete worked too but the left menu were not displayed.

The problem comes from filer loading jquery (1.11.3) unconditionally, overriding the site-level one.
I'm currently loading 2.1.4 for tinymce.

Thanks !

@jokerejoker
Copy link

I have the same error. I am not using mezzanine, but only autocomplete_light. My widgets show up perfectly fine, but I get the same JS error, and I to can trace it back to filer loading it's own version of jquery.

From what I have found the problem is with autocomplete light v2, which is no longer supported, where the JS jQuery is not scoped and therefor the yourlabsWidget function of jQuery does not exist on the loaded jQuery because filer override the jQuery object after the autocomplete light is initialized.

In my opinion the problem is with the code of autocomplete_light, but things like this only arises because filer as decided to load its own version of jQuery, which is, by my opinion a big design flaw, and will lead to more problems like this in the future.

@jokerejoker
Copy link

@frague59 My fix for now is to simple provide an empty file replacing the filer/js/libs/jquery.min.js, and all works just fine.

@stefanfoulis
Copy link
Contributor

ok. I wonder if we can just piggy-back on the jQuery provided by django admin? Usually @lory87 would tackle this kind of problem. But she is currently tied up in project work. It would be really awesome if someone could put together a pull-request. :-)

@stefanfoulis stefanfoulis added this to the 1.2.0 milestone Mar 30, 2016
@jokerejoker
Copy link

@stefanfoulis I don't have enough insight in the filer JS code to conclude that the django admin privided jQuery 1.11.2 is sufficient, but one solution I can think of is to map the django-filer provided jQuery to a custom variable instead of the standard $-variable, by using the noconflict method, like django.admin does with the django.jQuery variable.

I will try to find to time to test this and if it works provide a pull-request, though I still think that the best solution would be to be using the django.jQuery, also to follow the Django guidelines of DRY programming which the current solution is in a bit of a conflict with. ;)

@lory87
Copy link
Contributor

lory87 commented Apr 1, 2016

@stefanfoulis @jokerejoker @frague59 working on this issue.

@lory87
Copy link
Contributor

lory87 commented Apr 5, 2016

@jokerejoker @frague59 I did some fixes and merged them to develop branch. Can you tell me please if this change fixes the issue?

@gradel
Copy link

gradel commented Apr 11, 2016

I'm also trying to integrate filer with mezzanine, since I use django-widgy which uses filer too.
Got to work with 1.1.1 by disabling the admin_filer.css completely. Using these styles makes not only the sidebar disappear, but changes the design in various places of the site, which is grappelli based.
Same with develop, but then selecting files is also broken.
For me it seems like admin_filer.css has too much an effect outside of just the admin file widget, where it is declared as media (in develop-branch), making filer unusable in other contexts. That's unfortunate, since its the best file and image app I know for django.

@lory87
Copy link
Contributor

lory87 commented Apr 15, 2016

@gradel We could determine the problem and are working on it. Thanks for your feedback. We will let you know when we merged changes to develop branch.

/cc @stefanfoulis

@lory87
Copy link
Contributor

lory87 commented Apr 21, 2016

@gradel Issue is fixed and changes are merged to develop branch. Release is coming soon. Thank you for your feedback.

@gradel
Copy link

gradel commented Apr 21, 2016

Had a first look and you find me deeply impressed :)
Thanks a lot for this fantastic work!

@lory87 lory87 closed this as completed Apr 22, 2016
@lory87
Copy link
Contributor

lory87 commented Apr 25, 2016

@gradel Do you have any experience or do you know if mezzanine doesn't look on get parameters? Because search doesn't work there But parameter is correct.

@gradel
Copy link

gradel commented Apr 25, 2016

@lory87 Seems to work here, so I can't reproduce the issue so far:

bildschirmfoto vom 2016-04-25 11 24 17

@lory87
Copy link
Contributor

lory87 commented Apr 25, 2016

@gradel Thanks for your feedback. Maybe I missed something in config.

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

5 participants