Click a regular link and respond in a turbo-frame

Hey everyone :wave:

I have a weird use-case here and I’m not sure if it’s possible to do with Turbo alone.

I’d liek to be able to click a link which doesn’t have a data-turbo-frame attribute, and server-side, in the Rails controller, do some computations and in some scenarios I want that request response to behave as a turbo-frame response.
So from the server side to tell it "respond as if the link had data-turbo-frame="some-frame", and on the client-side, Turbo would see that and interpret that response accordingly.
It would pick up just that frame’s content and replace it on the page.

Not sure if this can be achieved using just Rails, Turbo, and the turbo-rails gem.

Thank you!

To give a bit of context into why I’m asking.

I have a route which will only populate a modal through a turbo frame. Always and always.
And I’d like to be able to write the link without passing the data param. Not only me, but also my users.

link_to “Open modal”, modal_path

Hey there Adrian.

This post might have what you need: How to create Modals with Rails and Hotwire (and Tailwind CSS) | Rails Designer. Check the Force a view in a modal section.

Good luck!