Using the following code i experience a strange problem. When I click and call showVacationModal data is retrieved fine from the server and result is displayed correctly. If i keep clicking the same person(id) it continues to work.
If I click a different person (eg. different id) with no vacations nothing is showed = OK.
The problem
Now when I click the first person again nothing is displayed. (data is retrieved fine in ajax call).
Any ideas?
My JS code:
var ViewModel = function () {
this.vacations = ko.mapping.fromJS(null);
};
var model = new ViewModel();
function showVacationModal(id) {
var model = {};
$.ajax({
type: "POST",
url: "Default.aspx/GetVacations",
data: "{personId: '" + id + "'}",
delay: 1,
contentType: "application/json; charset=utf-8",
dataType: "json",
success: function (msg) {
model.vacations = ko.mapping.fromJS(msg.d);
ko.applyBindings(model);
$('#vacationModal').modal('show')
}
});
}
My HTML:
<table>
<thead>
<tr>
<th>
First name
</th>
<th>
Last name
</th>
</tr>
</thead>
<tbody data-bind="foreach: vacations">
<tr>
<td data-bind="text: Id">
</td>
<td data-bind="text: PersonId">
</td>
<td data-bind="text: Begin">
</td>
</tr>
</tbody>
</table>