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

131
Views
¿Cómo ejecutar múltiples declaraciones dentro de un solo atributo Alpine.js?

Me gustaría ejecutar varias declaraciones dentro de un solo controlador de eventos Alpine.js (sin embargo, creo que podría generalizarse a cualquier atributo).

Un ejemplo de lo que me gustaría lograr:

 <button x-data @click="alert('first')" @click="alert('second')"> Click me </button>
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

Es posible si separa las declaraciones con un punto y coma :

 <button x-data @click="alert('first'); alert('second')"> Click me </button>
about 4 years ago · Juan Pablo Isaza Report

0

Puede extraer la lógica de su componente y agregar un identificador para el evento de clic.

 <div x-data="myComponent"> <button x-on:click.prevent="handleClick">Click me</button> </div> <script> const myComponent = () => { return { handleClick() { console.log('First event') console.log('Second event') } } } </script>
about 4 years ago · Juan Pablo Isaza Report
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!