Impossible to trigger a refresh

Created on 31 March 2023, over 1 year ago
Updated 20 September 2024, 8 days ago

Problem/Motivation

Currently it is impossible to trigger a refresh of a block after it has been initially loaded, unless you've set a refresh interval.

This happens because the entire block is replaced with the new block contents.

// Replacing block contents.
if (drupalSettings.block_ajax.blocks[blockId].block_ajax.refresh_block) {
  $block.html(data.content);
} else {
  $block.replaceWith(data.content);
}

This means that the RefreshAjaxBlock event is bound to an element that will not exist after the contents have been loaded.

$block.on('RefreshAjaxBlock', function () {
  // Execute the handler payload.
  ajaxBlockHandler($(this));
})

So this won't work:

$('#block-my-block').trigger('RefreshAjaxBlock');

Steps to reproduce

Proposed resolution

Don't remove the outer div.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

RTBC

Version

3.0

Component

Code

Created by

🇦🇺Australia imclean Tasmania

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024