Jul 9, 2024
0
Level 1
Wire & Alpine are not accessible in named slot of layout file
I have just noticed that $wire & alpine are not accessible in named slots. Doe anyone have any idea what could be the reason?
// layout.blade.php
...
<div>
{{ $header }}
</div>
{{ $slot }}
...
// page.blade.php
<?php
use Livewire\Attributes\Layout;
use Livewire\Volt\Component;
new #[Layout('layouts.layout')] class extends Component {
...
};
?>
@script
<script>
// some page script...
</script>
@endscript
<div>
<x-slot:header>
<!-- works-->
<x-primary-button onclick="console.log('hello')">Save</x-primary-button>
<!-- doesn't work-->
<x-primary-button @click="console.log('hello')">Save</x-primary-button>
<!-- Error-->
<x-primary-button onclick="console.log($wire)">Save</x-primary-button>
</x-slot:header>
</div>
Please or to participate in this conversation.