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

182
Views
Vue Js : form-data Event

Hello there #Vue.js2 I'm encountering a problem on creating a function called in a form submit event This function needs to take 2 parameters : EVENT and ID My problem now is when I call this function i can't specify the event param without having error so my formdata and my id will be undefined in my logs. Is there any better way to handle my form ?

 updatePost(event, id) { 
  const postId = id;
  const updatedPost = new FormData(event.target); // Any way to not use event param to save this ? 
  console.log(updatedPost, postId);
},
 // Call in my Template but : 
 <form @submit.prevent="updatePost(post.id)">

ps : form composed by 2 inputs type text and 1 input type file.Vue.js screenShot

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

The original event is available as $event inside the v-on: handler.

Docs: Methods in Inline Handlers

Sometimes we also need to access the original DOM event in an inline statement handler. You can pass it into a method using the special $event variable

So this should work:

 <form @submit.prevent="updatePost($event, post.id)">
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!