Questions tagged [javascript]
Use for questions about JavaScript code that is very specific to Drupal.
3,213 questions
1
vote
1
answer
80
views
Behaviors not working as expected
I am trying to understand and use Javascript a bit more in Drupal Webform. I have managed to create some simple javascript to prove that I can create a module, load a library correctly and get a ...
0
votes
1
answer
102
views
Storybook always shows an error
I have installed the Storybook module, which converts .stories.twig files into .stories.json files.
I have the following lines added to the package.json file.
"@storybook/addon-a11y": "^...
0
votes
1
answer
79
views
What version of jQuery does drupal 10.3.9 uses? [duplicate]
What version of jQuery uses the drupal 10.3.9 by default?
0
votes
1
answer
66
views
Behavios scripts do not work
Migrated website from 7 to 10, but the jQuery scripts do not work anymore.
Code:
(function ($, Drupal, window, document, undefined) {
Drupal.behaviors.myLinebreak = {
attach: function (context, ...
0
votes
1
answer
140
views
How can I force Composer to read the dependent library package from jFrog Artifactory?
We are encountering an issue where we want to download packages from JFrog Artifactory instead of the internet.
We are able to route the composer root and dependent packages from JFrog Artifactory; ...
0
votes
1
answer
52
views
Background Image module not blurring for Anonymous Users [closed]
Issue
I have a Drupal 10 site that doesn't load some dependencies for Anonymous users and breaks the blur effect for one of my modules.
I used the Background Image module to create a page with a ...
0
votes
1
answer
120
views
How can I add script initialization in the paragraph template and substitute the desired value?
I have a paragraph content builder that has a countdown element. Moreover, this element, like other types of paragraphs, can be added an unlimited number of times. This means that the script must be ...
-4
votes
1
answer
227
views
Add Javascript to a specific 'Basic page' or node based on its title
In a Drupal 10 site I have a page (content type: Basic page) that needs a small Javascript fragment defined in a Javascript file that was added as an asset to the theme.libraries.yml file. I don't ...
0
votes
1
answer
67
views
Libraries override jquery_ui_accordion
How can i override jquery_ui_accordion? I can't figure out how.
libraries-override:
# Does not work?
jquery_ui_accordion/accordion:
css:
component:
assets/vendor/...
2
votes
0
answers
76
views
Javascript library with "modulepreload"
Lately working with svelte in a project. The generated HTML uses Javascript with link and modulepreload:
<!doctype html>
<html>
<head>
...
<link rel="modulepreload&...
-1
votes
1
answer
104
views
Give all users including anonymous ones the option to add nodes of certain content types to a list like "interested", at least once
I'd like to give all users including anonymous ones the option to add nodes of certain content types to a list like "interested", several times.
The logic is identical to that of a shopping ...
2
votes
2
answers
980
views
How to hide CKEditor5 toolbar plugin based on user permissions?
I am using Drupal 10, CKEditor5, and a text format that has a good number of options in the toolbar including the source editing plugin. I have a custom module that defines a custom permission that I ...
0
votes
1
answer
98
views
Respond to "dialog:afterclose" once
I'm trying to figure out how to respond to dialog:afterclose only once, and I'm not having any luck getting the syntax right (and I'm having trouble finding resources because most search results refer ...
0
votes
1
answer
137
views
A Drupal.behaviors stops working when I update the module
I have checked the field_ui core module to understand how to update my code, but it doesn't seems to work.
This is the code.
(function ($, Drupal, drupalSettings) {
Drupal.behaviors....
0
votes
0
answers
122
views
Form States not working when compressed javascript is enabled
I have visible states setup for a 2 fields that correctly work when javascript aggregation is disabled. When I turn JS aggregation on both fields are visible no matter what option I select on the ...
0
votes
1
answer
250
views
How can I add an external/third party library with type = 'module' using drupal_add_js()?
drupal_add_js('path_to_external_JS_file_on_CDN', [
'every_page' => TRUE,
'type' => 'external',
'defer' => 'defer',
'attributes' => [
'async' => true,
'type' =...
0
votes
0
answers
143
views
Select media popup is not opening after upgrade ckeditor from 4 to 5 Drupal
We have drupal version 9.5.7 in our website, When we had upgrade ckeditor4 to ckeditor5 then Select media popup(for image and video) is not opening.
Console error: ajax.js?v=9.5.7:411 An error ...
0
votes
0
answers
71
views
Use javascript code in a specific div of the webform page
I have a website that was set up using Webforms with page breaks. So on the same URL, there are multiple "pages" and div blocks on each page, with a progress bar on top so you know what &...
1
vote
1
answer
393
views
Use AJAX On Node Add Form To Change Field Required Status
On a node/add form I have a pair of fields that need to be able to control one another. The first field allows a user to enter a birthdate, the second field allows the user to say the birthdate is ...
0
votes
0
answers
146
views
Views UI javascript is broken
I discovered today that the Views UI is broken on one my sites. I'm not sure when it broke, because the Views UI is not one of the things I check after updates.
I'm currently at 9.5.3.
My Views UI ...
0
votes
1
answer
399
views
Add js library to custom ckeditor4 plugin
How can an external JS library be integrated into Drupal for use within a custom Ckeditor4 plugin?
My custom plugin needs to set a javascript cookie each time I click on the plugin icon and unset when ...
0
votes
1
answer
76
views
How do I lock down a child theme to use jQuery 3.6.0?
My older site uses bootstrap 3 and has been working great when accessed from a mobile phone and the hamburger menu kicks in, but something has happened in jQuery 3.6.2 (In Drupal 9.5.0) that causes ...
1
vote
1
answer
138
views
Can we export json schemas for type script usage?
We have a Drupal installation that acts as a backend and a front end that uses the HttpClientModule from Angular to query this data.
Thanks to the typescript base, we can provide the functions of this ...
0
votes
3
answers
2k
views
Google API callback doesn't work
I've created this javascript (delivery.js) that is supposed to take a pre-existing div on a webform page and append a Google Map to it, along with a few circles of differing radius.
Here is my ...
-2
votes
2
answers
837
views
How to load a dependency in the <head> in drupal 9?
I have followed the official documentation, but it doesn't work
global-styling:
version: VERSION
js:
js/bootstrap.min.js: {}
js/custom.js: {}
css:
component:
css/style.css:...