Created
June 6, 2020 08:29
-
-
Save tslim/bf3abbf107e418cc82d55ff9ecbd60fb to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def handle_params(params, uri, socket) do | |
{:noreply, | |
socket | |
|> assign(:page, params["page"] || socket.assigns.page) | |
|> assign(:order_by, params["order_by"] || socket.assigns.order_by) | |
|> apply_action(socket.assigns.live_action, params) | |
|> fetch_users()} | |
end | |
def handle_event("search", %{"keyword" => keyword}, socket) do | |
{:noreply, | |
socket | |
|> assign(:keyword, keyword) | |
|> assign(:page, 1) | |
|> fetch_users() | |
|> push_patch(to: Routes.user_index_path(socket, :index, keyword: keyword))} | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment