Skip to content

Commit

Permalink
Tweet一覧部分のFrame化
Browse files Browse the repository at this point in the history
フォーム送信時、検索アイコンクリック時に一覧部分のみ更新する
  • Loading branch information
yakitorii committed Dec 12, 2022
1 parent bde8807 commit 399b3b0
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion hotwire-tw-demo/app/views/emotions/_new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
</ul>
</div>
<% end %>
<%= form_with model: @emotion || Emotion.new do |form| %>
<%= form_with model: @emotion || Emotion.new, data: { turbo_frame: "emotions" } do |form| %>
<div class="mb-3 row">
<%= form.label :icon, "きもち", class: "col-sm-2 col-form-label" %>
<div class="col-sm-10">
Expand Down
4 changes: 3 additions & 1 deletion hotwire-tw-demo/app/views/emotions/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@
</div>

<ol class="emotion-list w-100">
<%= render partial: "emotion", collection: @emotions %>
<%= turbo_frame_tag "emotions" do %>
<%= render partial: "emotion", collection: @emotions %>
<% end %>
</ol>
6 changes: 3 additions & 3 deletions hotwire-tw-demo/app/views/layouts/_sidebar.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,19 @@
<% end %>
</li>
<li>
<%= link_to root_path(icon: Emotion.icons[:love]), class: "nav-link #{active_css_class(root_path + "?icon=0")}" do %>
<%= link_to root_path(icon: Emotion.icons[:love]), class: "nav-link #{active_css_class(root_path + "?icon=0")}", data: { turbo_frame: "emotions" } do %>
<%== show_icon(Emotion.icons[:love], width: 30, height: 30) %>
<% end %>
</li>
<li>
<%= link_to root_path(icon: Emotion.icons[:angry]), class: "nav-link #{active_css_class(root_path + "?icon=1")}" do %>
<%= link_to root_path(icon: Emotion.icons[:angry]), class: "nav-link #{active_css_class(root_path + "?icon=1")}", data: { turbo_frame: "emotions" } do %>
<span class="nav-icon">
<%== show_icon(Emotion.icons[:angry], width: 30, height: 30) %>
</span>
<% end %>
</li>
<li>
<%= link_to root_path(icon: Emotion.icons[:smile]), class: "nav-link #{active_css_class(root_path + "?icon=2")}" do %>
<%= link_to root_path(icon: Emotion.icons[:smile]), class: "nav-link #{active_css_class(root_path + "?icon=2")}", data: { turbo_frame: "emotions" } do %>
<span class="nav-icon">
<%== show_icon(Emotion.icons[:smile], width: 30, height: 30) %>
</span>
Expand Down

0 comments on commit 399b3b0

Please sign in to comment.