Loading blocks / area's with ajax

Permalink
Hi all,

I am trying to load content from other page's to the .page div on the current page with Ajax. This can bee simply done with the $.load but of course the assets (css, js) from the block are not included this way.

I have also tried to load the area via the controller of the page type. it returns the date but still not assets.

//hardcoded the id's for now
 public function load_area_blocks($area = 'page-477', $pageID = 477)
    {
      //get blocks from the main-content area
      $blocks = Page::getByID($pageID)->getBlocks('main-content');
      $outputArea = Page::getCurrentPage()->getArea($area);
      $outputArea->disableControls();
      $outputArea->display(Page::getCurrentPage(), $blocks);
      exit;
    }


How can I make sure that via an ajax call the blocks are getting loaded in the current page area with the assets?

Thanks,

Rge

 
Kiesel replied on at Permalink Reply
Did you find an answer on this?

There was this add-on in 5.6:https://www.concrete5.org/marketplace/addons/blocks-by-ajax/...

Maybe if you study it's code you get an answer.
WillemAnchor replied on at Permalink Reply
WillemAnchor
Have a look at the core's stack block and also stack preview in the dashboard.