Skip to content

Removing jquery-ui from the admin template broke modeltranslation #1967

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

Closed
Remiz opened this issue Aug 18, 2020 · 7 comments
Closed

Removing jquery-ui from the admin template broke modeltranslation #1967

Remiz opened this issue Aug 18, 2020 · 7 comments

Comments

@Remiz
Copy link
Contributor

Remiz commented Aug 18, 2020

I updated a project with the newest version of Mezzanine and I noticed in the admin interface that the translated fields toggle stopped working properly. I think it's because jquery-ui is no longer included in the admin template, resulting in tabbed_translation_fields.js not properly loading:

VM246 jquery.js:4055 Uncaught TypeError: tabsContainer.tabs is not a function
    at Object.<anonymous> (VM250 tabbed_translation_fields.js:166)
    at Function.each (VM246 jquery.js:387)
    at createTabs (VM250 tabbed_translation_fields.js:136)
    at HTMLDocument.<anonymous> (VM250 tabbed_translation_fields.js:326)
    at mightThrow (VM246 jquery.js:3762)
    at process (VM246 jquery.js:3830)

Anyone else has the same issue with a multilingual admin interface?

@jerivas
Copy link
Collaborator

jerivas commented Aug 18, 2020

Just pushed a new commit restoring jQuery UI, please give it a try

@Remiz
Copy link
Contributor Author

Remiz commented Aug 18, 2020

I just tried and I have the same error. I double checked and jquery-ui is properly imported, so it looks like I was wrong in the first place, sorry about that. I suspect it has to do with the tabbed_translation_field.js file not being compatible with jquery 3.4, but I could be wrong again. I'll try to override my admin template to make it work and let you know.
EDIT: The error is actually different once jquery-ui is included:

VM564 jquery-3.4.1.js:3850 Uncaught TypeError: tabsContainer.tabs is not a function
    at Object.<anonymous> (VM572 tabbed_translation_fields.js:166)
    at Function.each (VM564 jquery-3.4.1.js:373)
    at createTabs (VM572 tabbed_translation_fields.js:136)
    at HTMLDocument.<anonymous> (VM572 tabbed_translation_fields.js:326)
    at mightThrow (VM564 jquery-3.4.1.js:3557)
    at process (VM564 jquery-3.4.1.js:3625)

@Remiz
Copy link
Contributor Author

Remiz commented Aug 19, 2020

So a bit more about my attempts at fixing the issue:

I'm pretty sure that the fact jquery-ui doesn't load is because there is a conflict about which version of jquery to use. I see it imported 3 times in my page source. I manage to have it partially fixed by forcing tabbed_translation_fields.js to use django.jQuery, by replacing this line

var jQuery = window.jQuery || $ || django.jQuery;

with

var jQuery = django.jQuery;

Doing so, I got it to work but for some reason the translation switch buttons are duplicated (the first one behaving weirdly and just hiding the field). I'll keep looking into it, but I think it would be helpful if someone with a simpler project could confirm that the error is not just on my end.

@dekomote
Copy link
Contributor

This PR #1982 fixes your issue. Hopefully it'll be merged soon.

@Remiz
Copy link
Contributor Author

Remiz commented Mar 30, 2021

I confirm that PR #1982 fixes the issue. Thanks @dekomote!

@github-actions
Copy link
Contributor

🎉 This issue has been resolved in version 5.0.0-rc.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions
Copy link
Contributor

🎉 This issue has been resolved in version 5.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants