extract element from object

8 views
Skip to first unread message

jjf...@gmail.com

unread,
Apr 21, 2014, 2:21:03 PM4/21/14
to knock...@googlegroups.com
I'm not sure why this doesn't work...

    viewModel.getSister = ko.computed(function () {
        var sisID = this.selectedSister().SisterID;
        console.log("Result: ", sisID);
        return ko.utils.arrayFilter(viewModel.bioArray, function (item) {
            return item.SisterID == sis;
        });
    }, viewModel);

I've tried many variations of the above. 

SisterID is an element of the object as seen here: 
Result:
Object {SisterID1141UsingName"Mary"FamilyName"Madeline"ReligiousName"Mary"BaptismalName"Mary Madeline"}

if I do this:
    viewModel.getSister = ko.computed(function () {
       
var sis = this.selectedSister();
        console
.log("Result: ", sis);
       
return ko.utils.arrayFilter(viewModel.bioArray, function (item) {
           
return item.SisterID == sis.SisterID();
       
});
   
}, viewModel);

Lars GBN

unread,
Apr 21, 2014, 5:59:35 PM4/21/14
to knock...@googlegroups.com, jjf...@gmail.com
I just want to make sure that you figured out that the `sis` inside the top arrayFilter callback should be `sisID`.
Reply all
Reply to author
Forward
0 new messages