jquery - Select all field values of an observable array in a comma separated string -
i've got observablearray this:
self.displaymessagecollection = ko.observablearray(); i'm getting collection , pushing items displaymessagecollection this:
self.displaymessagecollection.push({ messageid: msgid, loader: 'block', uploadopacity: 'uploadopacity', sentstatus: 'wait', chattype: self.tochattype() }); i need messageid field values comma seperated string array.
i know can loop items , messageid values. want know if can query on observablearray, i.e. somehow single query field values comma seperated string?
you can use built in map function on underlying array , , can use join function comma separated string:
self.displaymessagecollection().map(function(i) { return i.messageid }).join(",") if need logic multiple times can create helper function observable array.
Comments
Post a Comment