Ask A Question


You’re not receiving notifications from this thread.

Auto-removing notices from a turbo_stream

RJ McCollam asked in Rails

I am appending a notice partial via turbo_stream on a few actions for a model. I am running into an issue on figuring out the best way to remove these notices after a set period of time.

The actual javascript on doing it is fine, but with the content being added via a turbo_stream I am not sure how to watch for that.

I have tried wrapping the notice partial with a data-controller to load a stimulus controller, but that doesn't fire when this partial is added.

I also tried listening for turbo events like load, but that isn't triggered either when this partial gets added.

What can I listen to, if anything, to run JS after a turbo_steam even has taken place?


Do you mean like a flash notice? you can do it as a

function myFunction() {
  setTimeout(function(){ alert("Hello"); }, 3000);
Join the discussion
Create an account Log in

Want to stay up-to-date with Ruby on Rails?

Join 83,603+ developers who get early access to new tutorials, screencasts, articles, and more.

    We care about the protection of your data. Read our Privacy Policy.