I have created a custom module with ajax call, which are sending render form data that I receive in my ajax prototype in a js file like below.

Drupal.AjaxCommands.prototype.loadCommentFormCommand = function (ajax, response, status) {
    if ($('#comment-form-wrapper').length === 0) {

But it's showing me

context.querySelectorAll is not a function 

Error. Does anyone face similar error or have some solutions for this?


1 Answer 1


The first argument to Drupal.attachBehaviors is an object representing a DOM element, context. You're currently providing it with a string.

In your case the correct code will probably be something like:


You don't pass data to behaviours through the attachBehaviors method, instead stash it somewhere in a global scope and pick it up later.

For example you might choose the window, drupalSettings, or some other object, depending on your general requirements and any other required uses of that HTML data.

  • Hi Clive, Thanks for your quick answer, Let me implement this and will come to you soon.
    – Udit Rawat
    Apr 19, 2018 at 12:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.