knockout.js - KnockoutJS computed is undefined -


I have a calculation of two integer based observations that I am trying to convert to a time bar. It appears that it should be very easy to see the documentation, but I am getting an unspecified: Undefined value from my computed value, if it is difficult to follow then any kind of help is highly appreciated. This is my JS:

  var routine = function (routine_name, minute, second, duration, rest, round) {this.routine_name = ko.protectedObservable (routine_name); This.minutes = to Protected (minutes) protected; This.seconds = ko.protectedObservable (sec); //this.duration = Co-Protected Obsessive (period); This.rest = to Protected (rest); this.rounds = to Protected Obsessive (Chakkar || 1); this.duration = ko.computed (function () {this return.minutes + ':' + this.Sseconds;}); } Var RoutineModel = Function (Routine) {var itself = this; Self.routine_id = ko.observable (); Self.routine_name = ko.observable (); //self.duration = ko.observable (); self.minutes = ko.observable (); Itself .seconds = ko.observable (); self.rest = ko.observable (); Self. Round = to.sevable (); Self.workout_name = ko.observable (); Self.duration = ko.computed (function () {return self.minutes (+): '+ self.seconds ();}); this. Routines = Ko.Sourceable Array (routine); This.selectedRoutine = ko.observable (); this.addRoutine = function () {var newRootin = new routine ("new routine", 0, 0, 0, 0); self.Routines.push (newRoutine); self.selectedRoutine (newRoutine); }; this.acceptRoutineEdit = function () {var selectedRoutine = self.selectedRoutine (); SelectedRoutine.routine_name.commit (); SelectedRoutine.minutes.commit (); selectedRoutine.seconds.commit (); //selectedRoutine.duration.commit (); SelectedRoutine.rest.commit (); selectedRoutine.rounds.commit (); Self.selectedRoutine (zero); selectedRoutine.duration = ko.computed (function () {selected selected routine.minutes + ':' + selected routine.seconds;}); }; };    

Your duration has been calculated this < / Code> and being calculated with incorrect reference.

When you define computed , then you this is evaluated as your calculation:

  this.duration = ko.computed (function () {return.minutes () + ':' + this.Sseconds ();}, this);   

Do not use your other computers, this , so there is no such problem.

In addition to this, computed in and selected routine.duration is calculated, make sure that you view the work as a work to regain your value. To call:

  selected routine.minutes () + ':' + selectedRoutine.seconds ();    

Comments

Popular posts from this blog

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

jasper reports - How to center align barcode using jasperreports and barcode4j -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -