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

Options being duplicated between different instances of timer #50

Closed
IanCaz opened this issue Jan 11, 2016 · 4 comments
Closed

Options being duplicated between different instances of timer #50

IanCaz opened this issue Jan 11, 2016 · 4 comments

Comments

@IanCaz
Copy link
Contributor

IanCaz commented Jan 11, 2016

There appears to be an issue when creating multiple timers, where the "options" from the last instantiated timer, override the values for the previous timers. The most obvious example of this can be seen in the callback or format. In the example below, I have two divs, with the id's of timerTest1 & timerTest2.

            $("#timerTest1").timer({
                duration: '3s',
                format: '%H:%M:%S',
                callback: function () {
                    $("#timerTest1").css("color", "red");
                    alert("This is the timerTest1 callback");
                }
            });
            $("#timerTest2").timer({
                duration: '5s',
                format: '%M:%S',
                callback: function () {
                    $("#timerTest2").css("color", "green");
                    alert("This is the timerTest2 callback");
                }
            });

From digging through the source, it appears that in the "TIMER PROTOTYPE" section, the options object always has the values of the last iteration.

Sample file:
test.txt

@IanCaz
Copy link
Contributor Author

IanCaz commented Jan 12, 2016

Okay, I think I've found the culprit. I changed the $.extend line in the prototype & modified the secondsToTime to take a timer object as well. These two changes seem to have "fixed" the issue.
timer.jquery.js.txt

@walmik
Copy link
Owner

walmik commented Jan 12, 2016

Hey @IanCaz Thanks for identifying an issue and finding the fix for the same. Can you please submit a PR for this?

@IanCaz
Copy link
Contributor Author

IanCaz commented Jan 12, 2016

Alright, I think I finally got it done. My first time working with Git, so let me know if I need to do something differently.

@walmik
Copy link
Owner

walmik commented Jan 12, 2016

@IanCaz Thank you once again. I ve merged this in, made some minor changes to resolve jscs issues and bumped the version.

@walmik walmik closed this as completed Jan 12, 2016
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

2 participants