You can extend your binding handler with the help of some jQuery to work also with arrays:
ko.bindingHandlers.formatAttr = {
init: function(element, accessor) {
var value = accessor();
if (!$.isArray(value))
value = [value]
$.each(value, function(index, item){
$(element).attr(item.attr, composeString(item));
});
},
update: function(element, accessor) {
var value = accessor();
if (!$.isArray(value))
value = [value]
$.each(value, function(index, item){
$(element).attr(item.attr, composeString(item));
});
}
};
So now you can pass an array of { attr, prefix, suffix, value }
object as a parameter to your binding:
<input data-bind="formatAttr: [
{ attr: 'id', prefix: 'InterestedParty_', suffix: '__Id', value: $data.Guid },
{ attr: 'name', prefix: 'Other_', suffix: '__Name', value: $data.Name }]"
type="hidden" />
Demo JSFiddle.