I am trying to add a "data-bind" attribute to a div using jQuery as follows:
var messageViewModel = {
data: ko.observable({
message: response.message,
sendDateFmted: response.sendDateFmted,
messageId: response.messageId
})
};
$("<div>",{
class:"messageToAndFromOtherMember"
}).data("bind", "template: { name: 'message-template', data: data }").appendTo("#messagesToAndFromOtherMember");
ko.applyBindings(messageViewModel);
"data-bind" is required by KnockoutJs. However all I get is this empty div:
<div class="messageToAndFromOtherMember"></div>
Notice there is no such attribute as data-bind
and therefore the div remains empty...