Blear's avatar
Level 1

How to call the js function after re-rendering the livewire component?

I need to call ag-grid's update function after each re-render because otherwise an empty div is returned. the first time the table is initialized in window.onload. I am using newest version of livewire

0 likes
7 replies
nelson_mutane's avatar

@blear Did you tried to send events from livewire to browser? like this $this->dispatch('post-created'); on you livewire compenent

1 like
Blear's avatar
Level 1

@nelson_mutane yes, the problem is that, for example, I call the delete function and do dispatch('update'), then the function is called and only then the component rerenders (after calling ag grid again, so nothing actually happens). Its like call livewire function -> function dispatch event -> event rerun js -> component is re rendering without window.onload and i need call livewire function -> function -> component is re rendering without window.onload -> event rerun js but cannot do this

Blear's avatar
Level 1

@nelson_mutane So if i understand correctly, for now my table component is regular laravel component, and my Index component is livewire one. So i should change table component into livewire component and move Update, Edit, Delete functions there?

Blear's avatar
Level 1

@nelson_mutane Still have this problem i think i must somehow dispatch event after every re-render but dont have idea how to do it

Please or to participate in this conversation.