Turbo 8 - morph turbo-frame tag
<div data-turbo-permanent>
I will not change with morphing
</div>
app/views/questions/update.turbo_stream.slim
= turbo_stream.refresh(target: dom_id(@question))
= turbo_stream.update("progress") do
= render "unrelated_content/progress_percentage"
app/views/questions/show.html.slim
= render "questions/question", question: @question
app/views/questions/question.html.slim
= turbo_frame_tag dom_id(question) do
h3= question.text
strong Your answer:
= form_with model: question do |f|
= f.text_field :answer, 'data-turbo-permanent': true
= f.submit " submit"
class QuestionsController < V2::BaseController
before_action :set_question
def show
end
def update
@question.update(params.require(:question).permit(:answer))
respond_to do |format|
format.turbo_stream
end
end
private
def set_question
@question = current_user.questions.find(params[:id])
end
end
Dashboard
app/views/pages/dahboard.html.slim
h1 overview
- current_user.questions.each do |question|
= turbo_frame_tag dom_id(question), refresh: "morph", src: questions_path(question) do
| Loading questions form another endpoimnt, please wait ...
h2 Progress:
= render "unrelated_content/progress_percentage"
Sources: