Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

174
Views
x-cloak issue in Alpine JS and Phoenix(PETAL stack)

Im a newbie to JS and Phoenix (PETAL stack in general).Problem raised when I want to implement hidden content with Alpine JS. Here`s some code:

<div x-data="{ open: false }">
    <button @click=" open = ! open ">toggle</button>
    <div x-show="open" class="text-center" x-cloak>
       <p>content</p>
    </div>
</div>

So my idea is to show the content only when a user clicks the show button. But when I load the page the content is visible and I need to press the button twice to hide it. I tried to use x-cloak and x-if. Maybe Alpine does not work right for some reason in my project?

P.S. I added in root layout style, but still can`t get the right output

[x-cloak] { display: none !important; }
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!