2

It's not Drupal that sorts the drupalSettings array, but it's console.log() that sorts the properties of drupalSettings.options before outputting it. See Show original order of object properties in console.log where the answer explains this. If you really want to avoid console.log() sorts the object properties, you could call console.log() using code ...


1

This is possible in Drupal without Drupal knowing anything about it. I have done things like this before in Twig templates: {% if node.field_myfield is not empty %} <script> var request = new XMLHttpRequest(); request.open("GET", "/api/v1/auth/" + {{ node.id }} + '?s=' + Date.now()); request.responseType = "text"; request.onload = ...


1

"menu-item" is a global class which can be used with several links on your Drupal site, so you have to be more specific with your css selectors (for example use your block ID and then the selector will be "#yourBlockId .menu-item". Also I invite you to use jQuery library it will help you to simply implement your JS solution by using jQuery methods (addClass(...


Only top voted, non community-wiki answers of a minimum length are eligible