From 72162fc3516e31f944c3acc3ca93b4612ae9332d Mon Sep 17 00:00:00 2001 From: Nayan Khedkar Date: Mon, 4 Mar 2019 14:11:24 +0530 Subject: [PATCH 1/3] Fixed multiple call on language change. --- js/adapt-contrib-pageLevelProgress.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/adapt-contrib-pageLevelProgress.js b/js/adapt-contrib-pageLevelProgress.js index 1a7be60..cda9bb9 100644 --- a/js/adapt-contrib-pageLevelProgress.js +++ b/js/adapt-contrib-pageLevelProgress.js @@ -9,7 +9,7 @@ define([ var PageLevelProgress = Backbone.Controller.extend({ initialize: function() { - this.listenTo(Adapt, 'app:dataReady', this.onDataReady); + this.listenToOnce(Adapt, 'app:dataReady', this.onDataReady); }, getCourseConfig: function() { From fb82997b5c66bad9420bfdfb64614a90618c0533 Mon Sep 17 00:00:00 2001 From: Nayan Khedkar Date: Thu, 7 Mar 2019 10:23:02 +0530 Subject: [PATCH 2/3] removed listener on language change. --- js/adapt-contrib-pageLevelProgress.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/js/adapt-contrib-pageLevelProgress.js b/js/adapt-contrib-pageLevelProgress.js index cda9bb9..4774d28 100644 --- a/js/adapt-contrib-pageLevelProgress.js +++ b/js/adapt-contrib-pageLevelProgress.js @@ -9,7 +9,12 @@ define([ var PageLevelProgress = Backbone.Controller.extend({ initialize: function() { - this.listenToOnce(Adapt, 'app:dataReady', this.onDataReady); + Adapt.on({ + 'app:dataReady': this.onDataReady.bind(this), + 'app:languageChanged': function() { + this.stopListening(); + }.bind(this) + }); }, getCourseConfig: function() { From 1809f33ef2c8747a9ff64147bb82e971f11f1fad Mon Sep 17 00:00:00 2001 From: Nayan Khedkar Date: Thu, 7 Mar 2019 16:16:17 +0530 Subject: [PATCH 3/3] added comment --- js/adapt-contrib-pageLevelProgress.js | 1 + 1 file changed, 1 insertion(+) diff --git a/js/adapt-contrib-pageLevelProgress.js b/js/adapt-contrib-pageLevelProgress.js index 4774d28..28c952a 100644 --- a/js/adapt-contrib-pageLevelProgress.js +++ b/js/adapt-contrib-pageLevelProgress.js @@ -12,6 +12,7 @@ define([ Adapt.on({ 'app:dataReady': this.onDataReady.bind(this), 'app:languageChanged': function() { + // Remove events created by setUpEventListeners this.stopListening(); }.bind(this) });