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

181
Views
When I type to fast on input it renders the wrong div

I'm have to show two different dropdown in my input. I'm doing it by having an shouldShowWarningBox method that it's called every time the input is updated by the user an updates the value of showWarningBox. The point is, when I type to fast I receive a false showing the warning message, but it's not true. If I type slowly the first div is rendered.

I've tried with and without the debounce function, but the behavior is the same, just with a little delay.

Any ideas?

.html

<div v-if="!showWarningBox">
 //dropbox
</div>

<div v-if="showWarningBox">
 //warning message
</div>

.js

data () {
 return {
  showWarningBox: false,
 }
},
methods: {
 onInput (value) {
  this.debounce(this.shouldShowWarningBox(), 1000)
 },
 shouldShowWarningBox () {
  //conditional that changes showWarningBox
 },
 debounce (func, delay) {
  let id
 
  return (...args) => {
   if (id) clearTimeout(id)

   id = setTimeout(() => {
    func(...args)
   }, delay)
  }
 },
}
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

debounce returns a "debounced" function. You should save that function in a component property and call that debounced function on input:

data(){
  let debouncedFn = this.debounce(this.shouldShowWarningBox, 1000)
  return {
    debouncedInput: debouncedFn
  }
},
methods: {
 onInput (value) {
  this.debouncedInput()
 },
 //...
}
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!