Problem/Motivation
For this issue:
* Server-side-Ajax = Client requests an ajax endpoint; server determines the changes, the ajax-commands response is processed by ajax.js.
* Client-side-Ajax = Client requests some html page/snippet and inserts it at a location determined by the client (and unknown to the server)
This is important for embedding media if they carry some JS behaviors (like blazy).
Entity-embed and media library use clientside ajax and currently ignore all JS (and CSS) attachments, making embedded entities/media break. See #2882866: Provide a preview display setting for use in WYSIWYG editors, improves authoring ergonomics, #3084312: Make (embedded entities') JS work inside CKEditor.
As the related issue shows, loading JS correctly is nontrivial so we should not reinvent the wheel.
Proposed resolution
* Leverage the existing JS/CSS attachment logic in a helper for clientside ajax
* If necessary, port the improvements from #1988968: Drupal.ajax does not guarantee that "add new JS file to page" commands have finished before calling said JS
Remaining tasks
TBD
User interface changes
None.
API changes
Add said helper.
Data model changes
None.
Release notes snippet
None.
Comments
Comment #2
geek-merlinComment #3
geek-merlinComment #4
geek-merlinThe discussion in the other tickets indicates we might not need this for media / entity_embed. Otoh i remember i needed this for leaflet_map ajax (i worked around this using serverside ajax, but having this would make significant better DX here). So still an issue.
Comment #9
damienmckennaComment #12
nod_Core issue mentioned in the issue summary is now fixed for 9.5+ branches :) no need for a workaround