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
Comments
Comment #2
imclean commentedComment #3
grevil commentedI just ran into the same problem. The provided patch LGTM. This way we never remove the "block-ajax-placeholder" but it also wasn't removed before, when "refresh_block" and doesn't seem to cause any trouble.
RTBC!
Comment #4
anybodyComment #6
grevil commentedCreated an MR for easier review.
Comment #7
anybodyTotally makes sense to have this consistent. Also for outer callability. Confirming RTBC.
Can we get this merged?
Comment #9
anybody