I have created a custom module, which is working. Except the JavaScript, which is not being detected. I have been following the description at https://www.drupal.org/docs/8/api/javascript-api/javascript-api-overview and I have checked other modules.
What have I done to implement JavaScript? I have created a file with the following JavaScript content (location: MODULE-ROOT/js/info.js):
/** * @file * Info behaviors on node edit form. */ (function ($, window) { 'use strict'; Drupal.behaviors.nodeEditForm = { attach: function () { console.log('Hi there!'); } }; })(jQuery, window);
Then I have added the following content into my MODULE-NAME.libraries.yml file:
nodeEditForm: version: 'VERSION' js: js/info.js: {}
I expect to see “Hi there!” in my webdeveloper tools inside Google Chrome browser, after I flush the entire Drupal 8 and browser cache. I do not get any output there.
Is it a “must” to attach the JavaScript to any existing behavior? If so: how can I learn which behavior is tied to an node edit form?
Thanks for your attention.