Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

turbo frames: lazy loading collection elements #6

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/controllers/employees_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ def index

# GET /employees/1 or /employees/1.json
def show
sleep 1
end

# GET /employees/new
Expand Down
5 changes: 2 additions & 3 deletions app/views/employees/_employee.html.erb
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<div id="<%= dom_id employee %>">
<%= turbo_frame_tag employee do %>
<p>
<strong>First name:</strong>
<%= employee.first_name %>
Expand Down Expand Up @@ -28,5 +28,4 @@
<strong>Email:</strong>
<%= employee.email %>
</p>

</div>
<% end %>
10 changes: 6 additions & 4 deletions app/views/employees/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@

<div id="employees">
<% @employees.each do |employee| %>
<%= render employee %>
<p>
<%= link_to "Show this employee", employee %>
</p>
<%= turbo_frame_tag employee, loading: :lazy, src: employee_path(employee) do %>
<div style="height: 200px; background-color: silver">
Loading...
</div>
<% end %>
<br>
<% end %>
</div>

Expand Down