I have an custom module with Block:
namespace Drupal\generator\Plugin\Block;
use Drupal\Core\Block\BlockBase;
class GeneratorBlock extends BlockBase {
public function build() {
$form = \Drupal::formBuilder()->getForm('Drupal\generator\Form\ProjektForm');
return array(
'form' => $form,
'#attached' => array(
'library' => array(
'generator/generator-css'
),
),
);
}
}
All it does is placing some From in there with additional .css
file (from library). I can place this block via Admin -> Structure -> Block layout and it works fine.
What I want now is to load that block via Ajax (because I want to refresh the whole block in some cases). And by that I mean I want to load it into wrapper (like with $.load(...)
) or get the content of the block in JS variable (not the whole page with block, but just the rendered block).
I've found the tutorial for Drupal 7 on drupal.org, but I failed to port it to Drupal 8.