Summary
In this chapter, we took on the client side and talked about JavaScript and client-side capabilities in Drupal 9. We started with the approach we need to take when writing JavaScript in a Drupal context. We learned about behaviors, why they are important, and how to use them. We also saw how we can pass around data from the server (Drupal) to the client side and make use of it in JavaScript.
Funnily enough, we then switched to a no-JavaScript-allowed policy for the rest of the chapter. We did this to prove how powerful the Drupal Ajax API is, with which we can perform complex server-to-client interactions even if we are not frontend developers that can write JavaScript code. And to demonstrate the API, we first looked at how simple links can be turned into Ajax requests. We followed that up with an important refactor of our earlier product importer functionality, which relied on Ajax to make the Importer configuration entity form dynamic (dependent on the selected plugin...