Last active
December 14, 2017 20:15
-
-
Save ChrisMoney/aadd7a27ff82eb5081a1a658197ae124 to your computer and use it in GitHub Desktop.
Create Object in Knockout
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function Attachment(data) { | |
this.id = ko.observable(data.AttachmentId); | |
this.name = ko.observable(data.AttachmentName); | |
this.size = ko.observable(data.AttachmentSizeText); | |
this.isEmail = ko.observable(data.IsEmail); | |
} | |
// map data object from server to Knockout object | |
var mappedAttachments = $.map(data.detail.Attachments, function (item) { return new Attachment(item); }); | |
self.attachments(mappedAttachments); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment