Add possibility to nest turbo frames #296
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I often get the case where I would like to nest turbo frames.
Let's take the example of the
Articleand theCommentmodels of the dummy app. Let's imagine that on theArticles#indexpage, we display multiple articles and we want to be able to add comments to them directly from this page.When clicking on the "Add comment" button of the article with id 1, I need to append the new comment form on the right article, so I need a
<turbo-frame id="article_1_new_comment">. I would like to be able to write it like thisturbo_frame_tag(@article, Comment.new).When submitting the form, I need to add the created comment at the right position so again, I need the nesting
<turbo-frame id="article_1_comments">to be able to append the comment in the comments list of the article with id 1. I would like to be able to write it like thisturbo_frame_tag(@article, "comments").What do you think? It would be nice to have a convention to prevent each developer team from writing its own
nested_dom_idhelper.