I thought the mapping plugin should return an observable array but the obbservable array is empty even though 'resp' response from server has 1000s of elements.
Am I missing something here? Please see below.
<script type="text/javascript">
function tasksViewModel() {
var self = this;
self.tasks = ko.observableArray(null);
self.load = function () {
$.ajax({
url: '/api/benchmark',
success: function(resp) {
// This line isn't working!
self.tasks = ko.mapping.fromJS(resp);
},
dataType: 'json'
});
}
}
var viewModel = new tasksViewModel();
$(function () {
ko.applyBindings(viewModel);
viewModel.load();
});
</script>