Since no one answered my question, but Jerouen gave me a hint what to look at, I will try to answer my question with what I found. So:
1) You must use the scroll event
View
<div id="main" data-bind="foreach: items, event: { scroll: scrolled }"> <div data-bind="text: name"></div> </div>
ViewModel
var viewModel = { items: ko.observableArray([]), scrolled: function(data, event) { var elem = event.target; if (elem.scrollTop > (elem.scrollHeight - elem.offsetHeight - 200)) { getItems(20); } }, maxId: 0, pendingRequest: ko.observable(false) }; function getItems(cnt) { if (!viewModel.pendingRequest()) { var entries = []; for (var i = 0; i < cnt; i++) { var id = viewModel.maxId++; entries.push({ id: id, name: "Name" + id }); } viewModel.pendingRequest(true); $.ajax({ type: 'POST', url: '/echo/json/', data: {json: ko.toJSON(entries), delay: .1}, success: function(entries) { ko.utils.arrayForEach(entries, function(entry) { viewModel.items.push(entry); }); viewModel.pendingRequest(false); }, error: function() { viewModel.pendingRequest(false); }, dataType: 'json' }); } } ko.applyBindings(viewModel); getItems(20);
It was taken from here and similar approaches with scrollOptions here .
There is also an implementation of the MIT license .
Salvador dali
source share