Skip to content
This repository was archived by the owner on Mar 14, 2025. It is now read-only.

Multiple On Change Events #74

Closed
JeffBeltran opened this issue Apr 14, 2018 · 1 comment
Closed

Multiple On Change Events #74

JeffBeltran opened this issue Apr 14, 2018 · 1 comment
Labels

Comments

@JeffBeltran
Copy link

I'm submitting a ... (check one with "x")

[X] Bug report => search github for a similar issue or PR before submitting
[ ] Feature request
[ ] Other, please describe

Tell about your platform

  • flatPickr version : 4.x.x
  • Vue.js version : 2.1.x
  • Browser name and version : Chrome
  • This package version : 7

Current behavior
When i have two compoents on the same page if i change the second one it triggers the @on-change event twice

Expected behavior
should only trigger the event for the value that was updated

Minimal reproduction of the problem with instructions
https://jsfiddle.net/sedyybb7/

on that fiddle if you change the first one you will only get the 1 alert but if you change the 2nd one it will alert twice, for each component

Looks like #27 might be similar but as you can see from the fiddle it is still not working, not sure if it's the way im doing it? or if a bug.

As always, thanks for your time and creating this helpful package

@ankurk91
Copy link
Owner

ankurk91 commented Apr 14, 2018

@JeffBeltran
Thanks for catching this issue.
I will be releasing a new version soon (may be tomorrow).

What was the actual cause?

Same config object (via prop) was being used for two components. And each component was mutating this object.

How is fixed this issue?

Clone the config object before mutating it.

Meanwhile you can test the updated fiddle.
https://jsfiddle.net/sedyybb7/4/

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants