I created the connectedFilters.js file in /themes/custom/module/js/ with the following code.

(function ($, Drupal) {

    Drupal.behaviors.connectedFiltersBehavior = {
        attach: function (context, settings) {

            console.log("im working!");


})(jQuery, Drupal);

In module.libraries.yml I added the following lines.

    js/connectedFilters.js: {}
    - core/drupal
    - core/jquery

In the appropriate view, above the top HTML element I added {{ attach_library(‘module/connectedFilters’) }}.

When I refresh the page I get the following warning.

Warning: Division by zero in __TwigTemplate_803bc8c08db6c9bfff48088195ee1e9f3bfaa4c94fad1e00b868ab6b41a67f00->doDisplay() 

When I remove{{ attach_library(‘module/connectedFilters’) }}, the error goes away. Why?

  • 2
    ‘module/connectedFilters’ is not using the correct string delimiters. It should be 'module/connectedFilters'. (In the question, the difference is more evident.)
    – apaderno
    Commented May 2, 2019 at 18:02
  • Yep that was it, thank you.
    – plambre
    Commented May 2, 2019 at 18:19
  • {{ attach_library(‘module/connectedFilters’) }} is evaluating to 0/0 due to inappropriate inverted commas as mentioned by @kiamlaluno. Commented May 2, 2019 at 19:38
  • 2
    I'm fine if you close this, but it might be worth saving since the error message is so mysterious and doesn't relate to what caused the problem
    – plambre
    Commented May 2, 2019 at 19:38


Browse other questions tagged or ask your own question.