I am trying to render Knockout in jQuery append but it seems that the value fails to render. I need help on rendering the div as shown in the html into the jQuery append container.
var employees = [
{"firstName":"John", "lastName":"Doe"},
{"firstName":"Anna", "lastName":"Smith"},
{"firstName":"Peter","lastName": "Jones"}
];
var ViewModel = function() {
var self = this;
self.LoadMore = ko.observableArray([]);
self.OnLoadMoreClick = function() {
$.ajax({
$.each(employees, function(index,value) {
self.LoadMore.push(value);
});
$.each(employees, function(index,value) {
var container = '';
$('#LoadMoreContainer').append(container);
});
});
}
}
ko.applyBindings(new ViewModel());
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/knockout/3.2.0/knockout-min.js"></script>
<div id="LoadMoreContainer">
<!-- How to move this part into jquery append?
<!-- ko forEach: LoadMore -->
<div><div data-bind="firstName"></div><div data-bind="lastName"></div></div>
<!-- /ko -->
</div>
<div data-bind="click: OnLoadMoreClick">Load More</div>