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

how to show it? #1

Open
thearabbit opened this issue Feb 27, 2015 · 3 comments
Open

how to show it? #1

thearabbit opened this issue Feb 27, 2015 · 3 comments
Labels

Comments

@thearabbit
Copy link

I try this package like:

<template name="welcomeIndex">
    Clock: {{clock}}
</template>
----------------------
Template.welcomeIndex.helpers({
    clock: function () {
        var ExerciseClock = new ReactiveClock("ExerciseClock");
        ExerciseClock.start();
        ExerciseClock.stop();
        ExerciseClock.setElapsedSeconds(30);

        var elapsedSeconds = ExerciseClock.elapsedTime({format: '00:00:00'});
        return elapsedSeconds;
    }
});

don't show???
pl help me.

@aldeed
Copy link
Collaborator

aldeed commented Feb 27, 2015

You should declare outside of the helper since it will run multiple times and recreate the ExerciseClock object every time it runs.

<template name="welcomeIndex">
    Clock: {{clock}}
</template>
var ExerciseClock = new ReactiveClock("ExerciseClock");

Template.welcomeIndex.created = function () {
  ExerciseClock.setElapsedSeconds(30);
  ExerciseClock.start();
};

Template.welcomeIndex.destroyed = function () {
  ExerciseClock.stop();
};

Template.welcomeIndex.helpers({
    clock: function () {
        return ExerciseClock.elapsedTime({format: '00:00:00'});
    }
});

@thearabbit
Copy link
Author

thanks for your reply, how to format with date like moment js ("DDD MMM YYYY").

@aldeed
Copy link
Collaborator

aldeed commented Feb 28, 2015

It does not track the date, only elapsed seconds. You will have to add the elapsed seconds to the start time yourself and format using momentjs.

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

No branches or pull requests

2 participants