Ask A Question

Notifications

You’re not receiving notifications from this thread.

Executing javascript code that's returned within a Stimulus Reflex morph

Tom Iwaniec asked in Gems / Libraries

I've got Stimulus Reflex up and running well, but was wondering if there's a way to have it execute javascript commands sent back in script tags within HTML rendered partials when they're added to the page dom? Seems like they don't execute by default.

Reply

Got a good answer to this on the Stimulus Reflex Discord and figured I'd share here. Basically executing the JS could be a CSP issue, and you'd want to use CableReady operations, such as afterReflex etc to call whatever JS code you need executed.

Reply
Join the discussion
Create an account Log in

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

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

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