question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Function is getting called twice

See original GitHub issue

Below 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:closed
  • Created 6 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
sagalbotcommented, May 23, 2017

If you look at the source, onChange is what internally triggers the v-model syncing. Since you’re overriding it, selectedCategory won’t get updated. Remove your on-change callback and that watcher should fire.

0reactions
pradeepb6commented, May 23, 2017

That did the trick. Thank you. But still not sure why it did not work when used with function. 😃

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found