Skip to Content
Building Table Views with Phoenix LiveView
book

Building Table Views with Phoenix LiveView

by Peter Ullrich
January 2023
Intermediate to advanced
67 pages
1h 42m
English
Pragmatic Bookshelf
Content preview from Building Table Views with Phoenix LiveView

Creating the Pagination LiveComponent

Just as with sorting and filtering, we want to create a dedicated LiveComponent for the pagination functionality. Open up lib/meow_web/live/pagination_component.ex. Since the PaginationComponent is slightly larger than the previous LiveComponents, we’ll add the code in two steps instead of one. Please key in the following code first:

 defmodule​ MeowWeb.MeerkatLive.PaginationComponent ​do
 use​ MeowWeb, ​:live_component
 
  alias MeowWeb.Forms.PaginationForm
 
 def​ render(assigns) ​do
 ~​H​"""
  <div>
  <div>
  <%= for {page_number, current_page?} <- pages(@pagination) do %>
  <div phx-click="show_page"
  phx-value-page={page_number}
  phx-target={@myself}
  class={if current_page?, ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Craft GraphQL APIs in Elixir with Absinthe

Craft GraphQL APIs in Elixir with Absinthe

Bruce Williams, Ben Wilson
Realm of Racket

Realm of Racket

Conrad Barski M.D., David Van Horn, Eight Students of Northeastern University, Matthias Felleisen
What Employees Want Most in Uncertain Times

What Employees Want Most in Uncertain Times

Kristine W. Powers, Jessica B.B. Diaz
Real-Time Phoenix

Real-Time Phoenix

Stephen Bussey

Publisher Resources

ISBN: 9798888650097Errata Page