Function is getting called twice
See original GitHub issueBelow is the code I am using
<v-select v-model="selectedCategory" label="title" :on-change="setFeatures()" :options="categories"></v-select>
in methods: setFeatures: function () { console.log('here') }
As the page loads, I can see that, ‘here’ is getting printed twice.
One more weird bug:
<v-select v-model="selectedCategory" label="title" :on-change="setFeatures()" :options="categories"></v-select>
<v-select multiple v-model="selectedFeatures" label="feature_name" :options="features"></v-select>
Whenever I change the value in second select, ‘setFeatures’ function is getting called.
Issue Analytics
- State:
- Created 6 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
JS function being called twice? - javascript - Stack Overflow
The stack trace will let you see exactly where a function was called from, so you can see if it is being called...
Read more >My function being called twice for some reason? - Ask
It's called twice because you call it twice. In main: if (bLevelComplete) { ++LevelDifficulty; } if (AttemptedGuesses()) // here { ...
Read more >Preventing callbacks from accidentally being called twice
Wrap the callback so calling it twice throws an error. Another option is to keep track of whether the callback has already been...
Read more >Problem with function being called twice(?) - Codecademy
It doesn't pass the exercise, but the code runs. I assume it has something to do with the variable “price” confusing the computer...
Read more >Solution does not work unless function gets called twice in a row
Tell us what's happening: I got stuck in this problem so I peeked at the solution and almost wrote the same approach as...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
If you look at the source,
onChange
is what internally triggers thev-model
syncing. Since you’re overriding it,selectedCategory
won’t get updated. Remove youron-change
callback and that watcher should fire.That did the trick. Thank you. But still not sure why it did not work when used with function. 😃