I have the following code:
/* Sample data received from an ASP.Net WebApi ajax call */
var data = { [{"CodSeguro":676541,"NroSeguro":538178},{"CodSeguro":687069,"NroSeguro":577836]},{"CodSeguro":123,"NroSeguro":233]};
/*This function build the view model that will be shared by multiple pages*/
function getViewModel(data)
{
return ko.mapping.fromJS(data);
}
var viewModel = getViewModel(data);
ko.applyBindings(viewModel);
My Html look like these:
<table>
<thead>
<tr>
<th>CodSeguro</th>
<th>NroSeguro</th>
<th>NroEndoso</th>
</tr>
</thead>
<tbody data-bind="foreach: ">
<tr>
<td>
<span data-bind="text: CodSeguro"></span>
</td>
<td>
<span data-bind="text: NroSeguro"></span>
</td>
<td>
<span data-bind="text: NroEndoso"></span>
</td>
</tr>
Simply I dont know what to put after foreach in this line:
I really need to use the Mapping Plugin because there are a lot ob objects that i dont want to code in both places (js for knockout and c# in the service layer)
The fiddle is this:
Thanks!!!