How to Process a Turbo Stream Response in JavaScript using Stimulus

TL;DR: If you want to process (append, replace, etc.) a Turbo Stream response received from a fetch request in JavaScript, simply render the stream HTML with Turbo.renderStreamMessage(html) and let Turbo take care of it, instead of manipulating the DOM yourself.

Here's a simple Stimulus controller showing how it works:.


How to Process a Turbo Stream Response in JavaScript using Stimulus #ruby #rubydeveloper #rubyonrails #javascript #stimulus #turbo https://rubyonrails.ba/single/how-to-process-a-turbo-stream-response-in-javascript-using-stimulus

Nezir Zahirovic

Contractor Ruby On Rails (8+ years) / MCPD .Net / C# / Asp.Net / CSS / SQL / (11 years)

related articles