bastinald / laravel-livewire-modals

Dynamic Laravel Livewire Bootstrap modals.
66 stars 31 forks source link

can't push javascript to @stack('script') #12

Open afzalursyaref opened 2 years ago

afzalursyaref commented 2 years ago

i can't push javascript event listener, ex: livewire:load

michele-grifa commented 2 years ago

I also tried to push some script to a stack, but without success.

danyderigon commented 2 years ago

Hi. No update on this issue ?

danyderigon commented 2 years ago

Actually I just realized that we don't have to push in stack.

This method works very well on my side. Add this to your blade modal


<div>
    {{-- Your html--}}
</div>

<script type="text/javascript">

    $(document).ready(function () {

        // do whatever you want...

        window.Livewire.hook('component.initialized', (component) => {})
        window.Livewire.hook('element.initialized', (el, component) => {})
        window.Livewire.hook('element.updating', (fromEl, toEl, component) => {})
        window.Livewire.hook('element.updated', (el, component) => {})
        window.Livewire.hook('element.removed', (el, component) => {})
        window.Livewire.hook('message.sent', (message, component) => {})
        window.Livewire.hook('message.failed', (message, component) => {})
        window.Livewire.hook('message.received', (message, component) => {})
        window.Livewire.hook('message.processed', (message, component) => {})

    });

</script>