Hi!
I face with an issue that I don’t know how to solve or make some workaround.
I have a helper that I mount to assign a :view_mode
, that contains a string, generally with one of the next two values: “admin” and “dev”. Then I have a button that changes this assign and works nice. In this sense, I can have the next in my HTML:
<div :if={@view_mode == "dev"}>
Test
</div>
And the div
is just shown if @view_mode
is equal to “dev”. But I have an stream in which I try to use this mechanic but it doesn’t works. The HTML for the stream is like the next one:
<tbody id="items_stream" phx-update="stream">
<tr :for={{dom_id, {_id, item}} <- @streams.items} id={dom_id}>
<td>...</td>
<td>...</td>
</tr>
</tbody>
If I use :if={@view_mode == "dev"}
in any HTML element inside the “stream” (like in the example below), it doesn’t work as expected, nor hide nor display something already hidden. I also try to apply hidden
Tailwind’s class with a conditional inside class=
, but that doesn’t work too.
<tbody id="items_stream" phx-update="stream">
<tr :for={{dom_id, {_id, item}} <- @streams.items} id={dom_id}>
<td :if={@view_mode == "dev"}>...</td>
<td>...</td>
</tr>
</tbody>
I understand it may be related with the fact of being a stream and the use of phx-upadte="stream"
, does it has sense for you?
I am still thinking in a possible workaround for this issue I am having, but maybe someone of the community already knows how to face it!
Thanks in advance!
P.S. When I say it doesn’t works is because I use the same method outside the stream and inside it, outside works but inside not works.