akeeseth
akeeseth

Reputation: 845

Same value for each row in javascript

I have created one table as in http://jsfiddle.net/TQXja/14/

My need is for a user is Busy is true once, then it should be true for all tasks of that user. But its always taking the 1 row value as I am mapping array as in line no 24, var list I am mapping array to get distinct user list.

var list = ko.utils.arrayMap(self.tasks(), function (item) {
    if (distinctUsers.indexOf("|" + item.members) == -1) 
        distinctUsers += "|" + item.members;
        return item;
    }
});

Upvotes: 0

Views: 151

Answers (1)

Stokedout
Stokedout

Reputation: 11055

I would restructure your code and have instead a User object that holds the value isBusy. Within this User object have an observableArray of Goals like so:

function User(name, goals, isBusy, userPresence) {
    self.name = ko.observable(name);
    self.goals = ko.observableArray(goals);
    self.userPresence = userPresence;
}

function Goal(id, isPublic, note) {
    var self = this;

    self.goalId = ko.observable(id);
    self.isPublic = ko.observable(isPublic);
    self.note = ko.observable(note);
}

Upvotes: 1

Related Questions