Join GitHub today
GitHub is home to over 36 million developers working together to host and review code, manage projects, and build software together.Sign up
Switching from Structure to Content mode loads scripts in wrong order #6671
If you open a page in Structure mode, Django CMS will load the 'structure HTML' first and use an XHR call to fetch the actual contents of the page. When you close the Structure mode the page source is replaced with the actual contents of the paged, fetched earlier with the XHR call. All scripts on the page are loaded, but in sync instead of in order of appearance. This will cause libraries not being loaded in time.
The script-tags should be loaded / executed in order of appearance. E.g. If you have a jQuery script-tag and a jQuery plugin tag, its important to load jQuery before the plugin otherwise you'll get a jQuery is not defined.
The script-tags are loaded synchronously and executed once loaded, but not in order of appearance. E.g. the jQuery plugin can't find jQuery.
The contents of the body is appended by the
Short description: https://stackoverflow.com/a/21487979/522248
I'm not sure what would be the correct fix for this issue. The jQuery
Once option would be to dynamically replace all
Pro: it works like charm
Another option would be to roll back to the old behaviour where the original page is simply loaded and the
Maybe this might be a help: Personally I think it might be a plan to use a bundler for all your js code and init them with a single function. In our case we lost all references because of the DOM manipulations done after saving a plugin.
This pattern works for us:
A simplified example of that from our code... Since we write everything in React and don't use jQuery it wont work out of the box but maybe its a help?!: