I add a view with two exposed filters in a page through the preprocess of this page. When I load my page the first ajax request I do on my view works fine but the next one crash the javascript.

In summary here's what I do in my preprocess :

        $refView = Views::getView('ref');
        $refView->initDisplay();
        $refView->preExecute($args);
        $refView->execute();
        $renderedView = $refView->render();

On the client side, the error occurs in core/misc/ajax.js when the settings() function try to clean-up the expired settings of the drupalSettings.ajax object:

invalid 'in' operand ajaxSettings

drupalSettings.ajax appears to be null because the "drupal-settings-json" JSON of my page doesn't contain an ajax object after my first AJAX request --but does when I initially load my page.

Did I do something wrong with my view or is this a bug?

Either way, wouldn't it be more cautious to set the ajaxSettings variable this way in ajax.js' settings() function:
var ajaxSettings = drupalSettings.ajax || {};

Comments

yvesmarie created an issue. See original summary.

droplet’s picture

Status: Active » Postponed (maintainer needs more info)
yvesmarie’s picture

I currently can't update my project from GIT HEAD but the patches proposed in issue #2700495: Method removing expired drupalSettings.ajax tries to remove settings when there is no ajax defined are similar to my fix and solve the problem. Thanks!

droplet’s picture

Status: Postponed (maintainer needs more info) » Closed (duplicate)