plone / plone.app.widgets

Integrating plone.widgets into plone
Other
7 stars 38 forks source link

Every 3rd-5th edit page load, javascript is not initialised and widgets don't appear in debug mode #156

Open fredvd opened 7 years ago

fredvd commented 7 years ago

Using Plone 4.3.14, testing p.a.widgets 1.91. Created a site, installed p.a.widgets in the control panel.

Randomly the following error is shown in the browser console, which disables all widgets richtext-area's, the formtabs for categorisation, etc. from being initialised:

widgets.js:168 Uncaught Error: Mismatched anonymous define() module: function ($) { "use strict";

.... .....

http://requirejs.org/docs/errors.html#mismatch at makeError (http://localhost:8080/Plone/portal_javascripts/Sunburst%20Theme/++resource++plone.app.widgets.js:1:1396) at intakeDefines (http://localhost:8080/Plone/portal_javascripts/Sunburst%20Theme/++resource++plone.app.widgets.js:1:7745) at http://localhost:8080/Plone/portal_javascripts/Sunburst%20Theme/++resource++plone.app.widgets.js:1:16557

fredvd commented 7 years ago

Did some more checks:

(* The listed error is explained here: https://docs.plone.org/adapt-and-extend/theming/resourceregistry.html#the-mismatched-anonymous-define-error . So there's probably a mismatch between the p.a.widgets code using requireJS but inserted using normal javascript tags, but I have no idea how to fix this.

holdenhao commented 7 years ago

Your issue may be related to a bug in plone.app.jquerytools.form.js that I reported for plone.app.jquerytools.

fredvd commented 7 years ago

@holdenhao You might want to test plone.app.widgets directly from the 1.x branch on github and not the released 1.9.x versions on pypi. @thet and @petschki did some work this June in #167 and #168 to avoid collissions between old style javascripts and require.js . That's what's causing the mismatched anonymous defined error and I think also closes this issue.

The 1.x branch now has AFAIK very reliable TinyMCE loading also in development mode, I wasn't able to trigger an empty textarea while testing.

We might need a new 1.9.x release not to disappoint others testing p.a.widgets 1.x in Plone 4, this looks very promising now.

holdenhao commented 7 years ago

Thank you for letting me know. I will test from source. My temporary fix was to use version 1.9.0 of plone.app.jquerytools

fredvd commented 7 years ago

@holdenhao You might by onto some other issue as well, because after plone.app.jquerytools 1.9.0 jquery.form and jquery.tools were updated in this commit. https://github.com/plone/plone.app.jquerytools/commit/d1327d331cc0cb6bc0aad4fedd3a3033ca3d17e7

If you check the commit you'll see that 'support for AMD' was added in jquery.form, that could collide with the javascript loading of plone.app.widgets. Unfortunately I'm just starting with all this magical javascript bundling in the front end, so much of my debugging efforts go like "if there's smoke, there must be a fire" :-(