So currently I have a foreach loop that pulls in a list of messages, like a message center, where it shows the date/computed short subject/computed short message/status. So when it pulls in the short message I have it displayed as HTML since it's a message from an HTML Editor. But when it displays it displays with all the spaces and whatever else is in the message until it hits 25 characters.
How would I either remove the newline breaks from the html message upon adding it to the foreach loop? Or if I switched it over to the knockout text binding, remove the html characters and replace with a space?
Knockout:
self.ShortSubject = ko.computed(function () {
if (self.Subject().length < 20) {
return self.Subject();
}
else {
return self.Subject().substring(0, 20) + '...';
}
});
self.ShortMessage = ko.computed(function () {
if (self.Message().length < 50) {
return self.Message();
}
else {
return self.Message().substring(0, 50) + '...';
}
});
HTML:
<table class="table table-hover table-striped table-bordered text-center">
<thead>
<tr class="bg-success">
<th width="15%" class="table-title" data-bind="click: sortMessageType" style="cursor: pointer">Message Type </th>
<th width="25%" class="table-title" data-bind="click: sortSubject" style="cursor: pointer">Subject </th>
<th width="40%" class="table-title" data-bind="click: sortMessage" style="cursor: pointer">Message </th>
<th width="20%" class="table-title" data-bind="click: function(data, event) { sortDateCreated( $data, event ) }" style="cursor: pointer">Date Created </th>
</tr>
</thead>
<tbody data-bind="foreach: VisibleTemplates">
<tr>
<td class="mailbox-subject" data-bind="click: function(data, event) { $parent.selectTemplate( $data, event ) }, text: $data.MessageType"></td>
<td class="mailbox-subject" data-bind="click: function(data, event) { $parent.selectTemplate( $data, event ) }, text: $data.ShortSubject"></td>
<td class="mailbox-subject" data-bind="click: function(data, event) { $parent.selectTemplate( $data, event ) }, text: $data.ShortMessage"></td>
<td class="mailbox-subject" data-bind="click: function(data, event) { $parent.selectTemplate( $data, event ) }, text: $data.DateTime"></td>
</tr>
</tbody>
</table>