What is Happening by Adding Interactivity?
Let's see what will happen by adding interactivity in our application using Turbo frames.
We'll cover the following...
What’s happening in the Code?
By putting our HTML inside the <turbo-frame>
tag, we allow Turbo to control both the request to and the response from the server.
When we click the “Edit” button, we make a standard Rails GET
request, in this case for the ConcertController#edit
action. Rails handles this request normally for the most part. If we look in the browser network tab, we can see that the return value is the entire edit page, including the <h2>Editing Concert</h2>
header. Turbo inserts a Turbo-Frame
header into the request, and Rails recognizes it and optimizes accordingly by not rendering the layout in the return value. This is because the system assumes that the layout is not the part that the receiving Turbo Frame is interested in.
When the response comes back to the browser, Turbo intercepts it and looks ...