Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eventlisteners trigger on all instances #70

Closed
BabyDead opened this issue May 27, 2019 · 1 comment
Closed

Eventlisteners trigger on all instances #70

BabyDead opened this issue May 27, 2019 · 1 comment

Comments

@BabyDead
Copy link

I need multiple colorpickers on one single page, so I put them into an object through a loop.

basically (just an example of my steps, won't work):

var colorpickers = {};

elements.foreach(){
  colorpickers[this.id] = new colorPicker();
  colorpickers[this.id].on('color:change', function(color){
      // This will now trigger on the last or first one I set multiple times
  });
}

I can work around this for now by using external info to filter out which colorpicker is actually the one being triggered, I think... But I thought I should let you know that the instances share eventListeners. I'm sure that's not intended.

@BabyDead
Copy link
Author

For some reason it works now. I must've done something wrong in my code without realising. I'm sorry!

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

No branches or pull requests

1 participant