ityonemo
Anyone else having trouble with liveview phx-update/append docs?
Is anyone else having trouble with Phoenix Liveview’s phx-update? I feel like I must be doing something dumb or missing something key in the docs (Phoenix.LiveView — Phoenix LiveView v1.2.5).
This code doesn’t do the phx-update/append action, instead it seems to behave like it would if the phx-update term weren’t set.
defmodule LiveMessageTestWeb.TestMessage do
use Phoenix.LiveView
def render(assigns) do
~L"""
<div id="chat-messages" phx-update="append">
<%= for message <- @messages do %>
<p><%= message %></p>
<% end %>
</div>
"""
end
def mount(_session, socket) do
Process.send_after(self(), :ping, 100)
socket = assign(socket, messages: [])
{:ok, socket, temporary_assigns: [messages: []]}
end
def handle_info(:ping, socket) do
Process.send_after(self(), :ping, 200)
new_value = Enum.shuffle(?A..?Z) |> List.to_string
{:noreply, assign(socket, :messages, [new_value])}
end
end
First Post!
josevalim
Creator of Elixir
I believe your example should work. If you are updating from an old LiveView version, make sure you rebuild your JS.
You can also give the example app a try. It has examples with phx-update: GitHub - chrismccord/phoenix_live_view_example · GitHub
0
Most Liked
josevalim
Creator of Elixir
Popular in Questions
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum.
...
New
Why is it that the mnesia database isn’t the most preferred database for use in Elixir/Phoenix?
New
I am constructing a JSON object (map) and I need to conditionally set a field. I’m trying to write proper elixir-way code… and I’m at a l...
New
What is the idiomatic way of matching for not nil in Elixir?
E.g.,
First way:
defp halt_if_not_signed_in(conn, signed_in_account) when...
New
I’m not a pro in using Regex and can’t figure out why the following behaviour happens, especially if we take into account the difference ...
New
Good day to you all.
I have been struggling to get a query involving like and ilike to work.
Can anyone assist me on this, please?
pro...
New
Other popular topics
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine)
This is a plugin that adds support for Elixir to JetBrains IntelliJ...
New
Original source of discussion: This topic on the Pragmatic Programmers’ Functional Web Development with Elixir, OTP, and Phoenix forum.
...
New
What is the proper way to load a module from a file in to IEX?
In the python world, doing something like this pretty standard:
from ....
New
Hi everyone!
I need implement if…else if…else condition from my elixir code, and anymore of this control flow structures not work proper...
New
Hello all!
I am typing this post from my new MacBook Pro with the M1 chip. I’m loving it so far, and will probably use it as my daily dr...
New
I am trying to run a deploy with docker and I successfully runned with this command:
docker build -t romenigld/blog-prod .
but when I t...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #deployment
- #library
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #channels
- #elixirconf
- #exunit
- #discussion
- #code-sync
- #javascript
- #podcasts
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixir-ls
- #phoenix_html
- #iex
- #blog-post
- #graphql
- #genstage
- #ai
- #websockets
- #elixirconf-us
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









