I have a small module which contains the javascript library JSmol. This library renders molecular structures onscreen. The main module is called jmol. It contains an element, a twig template, a small javascript file, and the official JSmol library.
When I create an element on the page the element renders correctly, but the admin toolbar does not. Javascript console highlights 4 places that the "once" function is used, all in the code after the vendor library was included. One example is this:
TypeError: $(...).once is not a function
Drupal.behaviors.escapeAdmin = {
attach: function () {
var $toolbarEscape = $('[data-toolbar-escape-admin]').once('escapeAdmin');
my javascript file is quite simple:
(function ($, Drupal, drupalSettings, Jmol) {
'use strict';
Drupal.behaviors.jmol = {
attach: function () {
var Info = drupalSettings.jmol.mydiv.info;
$('#mydiv').html(Jmol.getAppletHtml("jmolApplet0", Info))
}
};
}(jQuery, Drupal, drupalSettings, Jmol));
Is it possible that the vendor code breaks this, or is it something that I have done?
Edit: here's my jmol.libraries.yml file:
jmol:
version: 1.x
js:
lib/JSmol.min.js: {}
js/jmol.js: {}
dependencies:
- core/drupalSettings
- core/jquery
- [I've tried adding core/jquery.once here to no avail]