Problem/Motivation
This is a follow-up of #3020716: Add vertical tabs style menu to media library. The current AJAX system supports opening dialogs by adding the use-ajax
class to a link. In the media library, once you are in the library, we have some links that need to replace parts of the dialog instead of close the current dialog and open a new one (which is an accessibility issue, see #3020716-18: Add vertical tabs style menu to media library).
The AJAX system supports replacing selectors with AJAX content, but to do that you currently have to do a custom implementation in JS. It would be great if the AJAX system provides an easier way to do this.
Proposed resolution
Add more flexibility to the current AJAX system for the use-ajax
class OR add a new class for this new use-case.
The following things would be nice:
- Add a class to a link so the AJAX behavior is automatically attached to the link.
- The href of the link will be used to fetch the new content.
- A data attribute to specify the selector that needs to be replaced.
- A data attribute to specify where the focus needs to go afterwards.
- A data attribute to specify the throbber.
Remaining tasks
Discuss how to implement this.
Write a patch.