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

HELP - Many instances #40

Closed
reynaldobarrosjr opened this issue May 8, 2018 · 3 comments
Closed

HELP - Many instances #40

reynaldobarrosjr opened this issue May 8, 2018 · 3 comments

Comments

@reynaldobarrosjr
Copy link

Could I to instantiate many Timers on same page? Each one with your behaviour?

@albert-gonzalez
Copy link
Owner

Hi!

Yeah, check out this example:

https://runkit.com/albert-gonzalez/5af1d31773b6190012b7d4dd

I configured two timers: one in normal mode and another in countdown mode. Each timer has a listener that prints a console.log with the current value of its value.

Best regards!

@reynaldobarrosjr
Copy link
Author

Im trying to do a more advanced thing.

I have a DOM with 3 timers. So I want to instantiate each of them dinamically. Now , I can just to maintain the last one after iteration.

I'm using a makeTimers function... take a look ...see if you can give me a light!

https://gist.github.com/trevobr/6a7882373376a1a4d0c01113537b57f6

@albert-gonzalez
Copy link
Owner

In line 29:

 local = '#arrayexample'+i;

try to change it to:

var  local = '#arrayexample'+i;

If you don't put var, it's a global variable and all the listeners are sharing it. Try this and let me know the result :)

By the way, in javascript arrays are dynamic, you can initialize them just with variable = [];

Best regards!

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

No branches or pull requests

2 participants