Hi,
I have made a block and all is working ok except I added an inline script inside 'dc-carousel-block-template.php'. I tried running this but found this does not work. It works if I run it inside 'enqueue_script' or 'enqueue_assets'. Is there an issue running inline scripts? or is this just WordPress preventing it?
Block
add_filter( 'rwmb_meta_boxes', function( $meta_boxes ) {
$meta_boxes[] = [
'title' => 'Carousel Block',
'id' => 'dc-carousel-block',
'description' => 'Carousel with product support',
'type' => 'block',
'icon' => 'screenoptions',
'category' => 'dc-blocks',
'context' => 'side',
'render_template' => __DIR__ . '/template/dc-carousel-block-template.php',
...
inside 'dc-carousel-block-template.php'
<script>
document.addEventListener( 'DOMContentLoaded', function() {
console.log('testing');
//test();
});
</script>
Thanks