I am trying to create a list of fading (WebSocket-)messages in the style of bootstraps 'alerts': success, info, error ...
<div data-bind="foreach: messages">
<div class="message" data-dind="css: $parent.foo($data)">
</div>
</div>
Each message should get it's style class dynamic in relation to it's property 'styleClass'.
var viewModel = {
messages: ko.observableArray(),
foo: function(data) {
return data.styleClass; // could be e.g. 'alert'
}
};
ko.applyBindings(viewModel);
What ist the right practice for this attempt? Is it to use 'pureComputeds'. In fact I tried several other approaches.. However I get no error but no added style class though.