Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
I'm using a sub-theme of pixture_reloaded. The html structure of a block on my page (I'm also using collapsiblock module) is
<section class="block collapsiblock-processed" id="block-elog-elog-dtm-listing">
<h2 class="block-title collapsiblock"><a role="link" href="#">Ongoing Downtime Events</a></h2>
<div class="ajaxblocks-wrapper-7" id="block-elog-elog_dtm_listing-ajax-content"></div>
</section>
Inside the ajaxblocksSetBlockContent function of the ajaxblocks.js file is the following code
var wrapper = $('#block-' + id + '-ajax-content');
if (!wrapper) {
return;
}
var context = wrapper.parent();
Drupal.detachBehaviors(context);
if (!context) {
return;
}
$('#block-' + id).addClass('ajaxblocks-loaded');
context.html(data['content']);
The context whose html is being replaced is my #block-elog-elog-dtm-listing section. When the html is replaced, I lose the "h2" title element inside of it. I have to make the following code change in ajaxblocks.js to make it work in this situation:
//context.html(data['content']);
wrapper.remove(); // Remove the ajaxblocks wrapper to get rid of "spinner" gif.
context.append(data['content']); // Append fetched content so we can keep block title
Comment | File | Size | Author |
---|---|---|---|
#2 | ajaxblocks-title-is-lost-2215737-1.patch | 459 bytes | tlarrieu |
Comments
Comment #1
tlarrieu CreditAttribution: tlarrieu commentedComment #2
tlarrieu CreditAttribution: tlarrieu commentedComment #3
helmo CreditAttribution: helmo as a volunteer and at Initfour websolutions commentedupdating status
Comment #4
helmo CreditAttribution: helmo as a volunteer and at Initfour websolutions commentedFound this to be a duplicate of #1973786: Block loose its title after ajax loading which is already tested