From 2e401263be7987b05019e26b08b2f700973f932e Mon Sep 17 00:00:00 2001 From: Austin Miller Date: Tue, 12 Sep 2017 11:10:24 -0700 Subject: [PATCH 1/2] Refresh the timer when attributes change Fix static render, especially when changing paths e.g app/timer/1 app/timer/2 app/timer/3 --- addon/components/x-timer.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/addon/components/x-timer.js b/addon/components/x-timer.js index adb1455..520ff09 100644 --- a/addon/components/x-timer.js +++ b/addon/components/x-timer.js @@ -11,11 +11,19 @@ export default Ember.Component.extend({ //TODO: check the usage of this variable isRunning: false, - didInsertElement: function(){ - if(this.get("autoStart")){ + _init: function _init() { + if (this.get("autoStart")) { this.send("start"); } }, + + didInsertElement: function(){ + this._init(); + }, + + didUpdateAttrs: function didUpdateAttrs() { + this._init(); + }, showStartBtn: function(){ return this.get("isStopWatch") || !this.get("autoStart"); From f220f4162e7af16771c929da0c5012d40f0952f4 Mon Sep 17 00:00:00 2001 From: Austin Date: Mon, 5 Feb 2018 15:27:25 -0800 Subject: [PATCH 2/2] Don't hardcode the element type --- app/templates/components/x-timer.hbs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/templates/components/x-timer.hbs b/app/templates/components/x-timer.hbs index bf039b6..5be99a8 100644 --- a/app/templates/components/x-timer.hbs +++ b/app/templates/components/x-timer.hbs @@ -1,4 +1,4 @@ -

{{duration}}

+{{duration}} {{#if showStartBtn}} {{/if}}