write javascript for Livewire

  @script
        <script>
            Livewire.hook('component.init', ({
                component,
                cleanup
            }) => {
                if (component.name == 'app.filament.pages.brf-revenue-page') {
                    inserthead()
                }

            })

            Livewire.hook('request', ({
                uri,
                options,
                payload,
                respond,
                succeed,
                fail
            }) => {
                inserthead()
            })


            function inserthead() {
                console.log('test');
                setTimeout(function() {
                    const thead = document.querySelector("thead");
                    const newHTML = '<tr class="bg-gray-50 dark:bg-white/5">test</tr>';
                    thead.insertAdjacentHTML('afterbegin', newHTML);
                }, 1500);

            }
        </script>
    @endscript

Posted

in

by

Tags:

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *