I have some thing like this
<td data-bind="text: email_sended">
<%= invite.email_send %>
</td>
function AdminInvitesViewModel() {
var self = this;
self.email_send = ko.observable();
}
ko.applyBindings(new AdminInvitesViewModel());
how can i initialize the observable from the content of the container ?
I this case the email send is a true/false value.
If this is necessary, then you can do this pretty easily with a custom binding.
Here is a binding that would set an existing observable using the element's innerText or create an observable if it doesn't exist.
You would use it like:
Note that the property name is in quotes, as the binding supports the observable not existing yet
Sample: http://jsfiddle.net/rniemeyer/kKBBj/