Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

DonNadie's avatar

*.classList.toggle() and *.classList.remove() not working using @script directive

I have a modal element in my template and the definition to the funtion than shows it and closes it , and even when the console.logs are printing data from the livewire event the classList.remove() has no effect over the class list of the element. does anyone can help me. does anyone have a clue on this.

1 like
1 reply
DonNadie's avatar

Hello Friends. Just to tell you all. I solved adding a async call to the function with a delay of 500ms , this is due to the livewire livecycle , because it reloads , so the call has to be next to that reload, reload time average was 250ms so i just put 500ms just in case. see setTimeout(() => { showModal('Product found with barcode: ' + product[0].gtin); }, 500);

1 like

Please or to participate in this conversation.