1

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.

connectedFilters:
  js:
    js/connectedFilters.js: {}
  dependencies:
    - 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?

closed as off-topic by kiamlaluno May 2 at 18:20

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question was caused by a problem that can no longer be reproduced, was solved by a cache clear, or was a simple typographical error. While similar questions may be on-topic here, this one was resolved in a manner unlikely to help future readers." – kiamlaluno
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    ‘module/connectedFilters’ is not using the correct string delimiters. It should be 'module/connectedFilters'. (In the question, the difference is more evident.) – kiamlaluno May 2 at 18:02
  • Yep that was it, thank you. – plambre May 2 at 18:19
  • {{ attach_library(‘module/connectedFilters’) }} is evaluating to 0/0 due to inappropriate inverted commas as mentioned by @kiamlaluno. – Vishal Kumar Sahu May 2 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 May 2 at 19:38

Browse other questions tagged or ask your own question.