In this article we will show a solution to add an ajax call to populate multiple information in a Drupal 8 form textarea element.
In this example, the script will autocomplete users list in the form for a custom module called MyModule. The user will enter first 2 letters of a name or email.
1) create a library
The autocomplete function as dependencies which are based on jQuery library.
2) JS script
The jQuery autocomplete.js file that we use is copied below. It is implemented as Drupal behaviors You need to add this file in MyModule/js/ folder.