kalkatfyodor

kalkatfyodor

Alpine.js x-transition not working in LiveView for <template> tag

I have this code inside liveview in Phoenix 1.6:

      <div x-data="{ open: false }" x-on:click.outside="open = false" x-on:keydown.escape="open = false">
        <button x-on:click="open = !open">
          Click me
        </button>
        <div x-show="open" x-transition.opacity>
          <div>
            <ul>
              <li>Dogs</li>
              <li>Cats</li>
              <li>Snakes</li>
            </ul>
          </div>
        </div>
      </div>

And the transition fade in/out animation works.

But when I do this:

      <div x-data="{ open: false }" x-on:click.outside="open = false" x-on:keydown.escape="open = false">
        <button x-on:click="open = !open">
          Click me
        </button>
        <template x-show="open" x-transition.opacity>
          <div>
            <ul>
              <li>Dogs</li>
              <li>Cats</li>
              <li>Snakes</li>
            </ul>
          </div>
        </template>
      </div>

It doesn’t. In fact nothing shows up at all and I have to change x-show to x-if to at least be able to make the show hide work albeit without any fade in/out effect at all:

      <div x-data="{ open: false }" x-on:click.outside="open = false" x-on:keydown.escape="open = false">
        <button x-on:click="open = !open">
          Click me
        </button>
        <template x-if="open" x-transition.opacity>
          <div>
            <ul>
              <li>Dogs</li>
              <li>Cats</li>
              <li>Snakes</li>
            </ul>
          </div>
        </template>
      </div>

How can I make this transition to work on the <template> element?

Most Liked

Where Next?

Popular in Questions Top

9mm
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
Harrisonl
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
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New
mcarvalho
What is the difference between System.get_env and Application.get_env? For example, what are best practices to use one versus another.
New
fireproofsocks
Forgive me if this is obvious, but how does one delete a database record WITHOUT selecting it first? Ecto.Repo — Ecto v3.14.0 has exampl...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
romenigld
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
nsuchy
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

Other popular topics Top

msaraiva
Surface is an experimental library built on top of Phoenix LiveView and its new LiveComponent API that aims to provide a more declarative...
564 43757 214
New
joeerl
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
SoCreat
i’m a new one to elixir which editor can i use vs code? or atom? Thanks! :smiley:
New
grych
Hi folks, Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
639 52673 488
New
ashish173
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
KronicDeth
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine) This is a plugin that adds support for Elixir to JetBrains IntelliJ...
289 36352 110
New
klo
Got a question about when to concat vs. prepending items to list then reversing to achieve appending. So i know lists boil down to [1 | ...
New
joaquinalcerro
Hi there, I am working with Ecto-Postgresql and I need to call all of the records from a specific table but the table has 40,000 records...
New
jaysoifer
Is there a way to rollback a specific migration and only that one (“skipping” all the other ones)? Would mix ecto.rollback -v 200809061...
New
jononomo
For some reason my phoenix channels are working for me in my local dev environment, but as soon as I deploy via Docker, I get a 403 error...
New

Latest on Elixir Forum

We're in Beta

About us Mission Statement