function make the model null

334 views
Skip to first unread message

Mahmoud Khedr

unread,
Feb 10, 2024, 5:06:46 AMFeb 10
to KnockoutJS
var Mapping = {
    'EmployeeAttendances': {
        key: function (ro) {
            return ko.utils.unwrapObservable(ro.EmployeeId);
        },
        create: function (options) {
            return new AttendanceDetail(options.data);
        }
    }
};



AttendanceDetail = function (data) {

    var self = this;
    ko.mapping.fromJS(data, Mapping, self);

   


    self.WorkingHoures = ko.pureComputed(function () {

     
            var TimeIn = new Date(self.TimeIn());
            var TimeOut = new Date(self.TimeOut());

            var timeDifference = TimeOut - TimeIn;

            var seconds = Math.floor(timeDifference / 1000);
            var minutes = Math.floor(seconds / 60);
            var hours = Math.floor(minutes / 60);

            var formattedResult = (minutes % 60) + " : " + hours;

            return formattedResult
       
    });
}

If I activate the function above, the model returns null. Can anyone help me, please?
Reply all
Reply to author
Forward
0 new messages