Quantcast
Channel: Issues for Drupal core
Viewing all articles
Browse latest Browse all 293239

View refresh: multiple ajax calls (Drupal 8/9/10)

$
0
0

Problem/Motivation

The Views HTML DIV element has multiple 'RefreshView' event handlers, when it should only have one.

This because:

  1. Drupal.behaviors.ViewsAjaxView.attach is run for each loaded html (html page + big piped blocks)
  2. which runs Drupal.views.ajaxView(ajaxViews[i])
  3. then
    const selfSettings = $.extend({}, this.element_settings, {
      event: 'RefreshView',
      base: this.selector,
      element: this.$view.get(0),
    });
    this.refreshViewAjax = Drupal.ajax(selfSettings)
  4. which adds the event handler again and again for each time behaviors attached is called.

Therefore when running JavaScript jQuery('.view-myviewid').triggerHandler('RefreshView'); many ajax calls are run instead of just one.

This is already fixed in Drupal 7 views. @see #2415027: View refresh: multiple ajax calls

Steps to reproduce

Run JavaScript jQuery('.view-myviewid').triggerHandler('RefreshView'); in web browser console and many ajax calls are run instead of just one.

Proposed resolution

Add once() to code to do preflight check before Drupal.ajax(selfSettings)

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet


Viewing all articles
Browse latest Browse all 293239

Trending Articles