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

Document AJAX conventions that prevent unexpected behaviour.

$
0
0

Problem/Motivation

When a part of the DOM is replaced using Drupal core's AJAX capabilities, any behaviour attached to a nested element does not run if the replacement is largely the same as the original.

Steps to reproduce

  1. Fresh install of Drupal
  2. Install the attached test module
  3. Go to /ajax-test
  4. Open the browser console
  5. Click "What is the time"
  6. Observe the console to see the results of console.log(context)
  7. Click "What is the time" again
  8. Observe the console to see the results of console.log(context)

Desired behaviour: The attached JS behaviour should run each time and log the context to console.
Current behaviour: The attached JS behaviour only runs the first time the AJAX replacement occurs.

This issue can be worked around by causing AJAX to replace the affected markup with an empty div, then placing the replacement markup. Uncomment line 66 of \Drupal\ajax_test\Controller\AjaxTestController to see this in action.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet


Viewing all articles
Browse latest Browse all 293522

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>