shahryarjb
LiveView has a problem with input name id
if I put this <input type="hidden" name="id" value="<%= item.id %>"> line in lee file LiveView in handle event repeat html tags
but if I change name to sthid, it works as well, I think id name is one of the parameters we shouldn’t use them in our source.
<div class="col-md-3" data-toggle="collapse" data-target="#FoodS" aria-expanded="false" phx-click="show-category-foods" phx-value-category-id="<%= category.id %>">
...
....
.....
......
<div class="spacer20"> </div>
<div class="col-md-11 mx-auto collapse" id="FoodS">
<div class="row">
<%= for item <- @foods do %>
<div class="col-md-3">
<form phx-submit="save-client-food">
<div class="foodbox text-center" data-mh="landing-cards">
<img class="u-mb-small img-fluid" src="<%= item.image %>">
<div class="spacer20"> </div>
<h5 class="u-h6 u-text-bold u-mb-small text-center"><%= item.title %></h5>
</div>
<div class="spacer20"> </div>
<div class="row text-center mx-auto">
<button type="submit" class="btn btn-outline-danger mr-3">انتخاب</button>
<input type="text" class="form-control col-md-6 mr-3" name="number" placeholder="انتخاب"/>
</div>
<input type="hidden" name="foodid" value="<%= item.id %>">
</form>
<div class="spacer20"> </div>
</div>
<% end %>
</div>
</div>
handle_event
def handle_event("show-category-foods", %{"category-id" => category_id}, socket) do
{:noreply, assign(socket, foods: CategoryQuery.show_category_foods(category_id))}
end
First Post!
slouchpie
I do not think this is a LiveView bug.
<form id="my-form">
<input name="id">
</form>
If the form is re-rendered in any way, it will be duplicated in the HTML, as you say.
But you can see in the devtools console that
document.querySelector("#my-form").id
does not return a string (like every other HTML element we are used to) but instead returns the child input with name “id”.
I
0
Last Post!
slouchpie
Popular in Questions
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
lets say i have a sample like
a = 20; b = 10;
if (a > b) do
{:ok, "a"}
end
if (a < b) do
{:ok, b}
end
if (a == b) do
{:ok, "equa...
New
I wanted to check elixir version in phoenix because i found that my elixir is 1.5 but when i use Enum.chunk_by it said the function is un...
New
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
Hi,
I have to write a raw query for one of my project. But till now I have used ecto queries and don’t have much experience writing raw ...
New
We have an ECS cluster with 4 services, where each task joins a single cluster, via discovery ECS discovery service.
Currently when I de...
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
Hello, how can I check the Phoenix version ?
Thanks !
New
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
What’s the safe way to decode a JSON string into a struct? I want to avoid calling String.to_atom. Jason.decode can give me a map with st...
New
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
New
Erlang/OTP 25 [erts-13.2.2] [source] [64-bit] [smp:8:8] [ds:8:8:10] [async-threads:1]
15:22:35.803 [error] gen_event {lager_file_backend...
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
- #supervisor
- #elixirconf-us
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #security
- #hex









