I am able to repeatably use views to reproduce an error in ajax.js on line 1213. I'll describe the steps to reproduce this below, but let me start with the error:

Uncaught TypeError: Cannot use 'in' operator to search for '.js-view-dom-id-0bafb4700aa872a1159d506d9b8134636b67e818422457e6efe5345581acd38c' in undefined

Line 1213 is the one below with " if (selector in ajaxSettings) {".

from ajax.js lines 1202-1207
    settings: function (ajax, response, status) {
      var ajaxSettings = drupalSettings.ajax;

      // Clean up drupalSettings.ajax.
      Drupal.ajax.expired().forEach(function (instance) {
        // If the Ajax object has been created through drupalSettings.ajax
        // it will have a selector. When there is no selector the object
        // has been initialized with a special class name picked up by the
        // Ajax behavior.
        if (instance.selector) {
          var selector = instance.selector.replace('#', '');
          if (selector in ajaxSettings) {
            delete ajaxSettings[selector];
          }
        }
      });

I have run through this in the debugger and line 1204 ALWAYS leaves ajaxSettings undefined when trying to assign it from drupalSettings.ajax. Sometimes the following forEach loop has instances and sometimes it does not (I'll explain more below) but ajaxSettings never seems to get a value based on what I have seen.

To reproduce this, I have created a view with an exposed filter using "Taxonomy Has Term", showing my taxonomy tag terms in a select list. I then enable the use of ajax for the view, which can be either a page or a block (both show the same error). The first time you select a tag and press "Apply" to update the view, it works without error. That is because the forEach loop that I mentioned above does not execute, presumably because there are no "expired" instances.

THE SECOND TIME I press "Apply" to update the view, the forEach loop has an instance so line 1213 is evaluated and fails because ajaxSetings is undefined.

I can't figure out why ajaxSettings is always undefined. At this point, I need someone to help debug this further.

For what it's worth, the call stack when the error occurs is:

(anonymous function)	@	ajax.js?v=8.1.0:1213
Drupal.AjaxCommands.settings	@	ajax.js?v=8.1.0:1206
Drupal.Ajax.success	@	ajax.js?v=8.1.0:864
Drupal.Ajax.ajax.options.success	@	ajax.js?v=8.1.0:505
t.success	@	jquery.form.min.js?v=3.51:11
j	@	jquery.js:3099
k.fireWith	@	jquery.js:3211
x	@	jquery.js:8264
(anonymous function)	@	jquery.js:8605

This is running on Ubuntu 16.04 w/PHP7 so it's certainly possible that something about PHP7 is causing this.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

carteriii created an issue. See original summary.

Flodevelop’s picture

Hello,

I had the same error.

To fix this temporary, add a condition to know if ajaxsettings is undefined :

// fix temp : when reload exposed filter in ajax view
if (ajaxSettings != undefined) {
  if (selector in ajaxSettings) {
    delete ajaxSettings[selector];
  }
}

When i use the filter for the second time, it seems to work.

Best

szeidler’s picture

Status: Active » Closed (duplicate)
FileSize
1.41 KB

It is fixed in 8.1-dev, but as I also need a patch for my live-environments I provide a patch here, that is using the current approach to solve it.
All in all the problem seems to be resolved in https://www.drupal.org/node/2561619.