Skip to content

Commit

Permalink
Change to use people endpoint for lazy-loading demo
Browse files Browse the repository at this point in the history
  • Loading branch information
yuriy-fix committed Oct 3, 2018
1 parent f2ed635 commit db2d902
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions demo/combo-box-basic-demos.html
Expand Up @@ -83,19 +83,22 @@ <h3>Lazy Loading</h3>
</p>
<vaadin-demo-snippet id="combo-box-basic-demos-lazy-loading">
<template preserve-content>
<vaadin-combo-box label="Country"></vaadin-combo-box>
<vaadin-combo-box item-value-path="lastName" item-label-path="lastName" label="Person"></vaadin-combo-box>
<script>
window.addDemoReadyListener('#combo-box-basic-demos-lazy-loading', function(document) {
const combo = document.querySelector('vaadin-combo-box');

combo.dataProvider = function(params, callback) {
var xhr = new XMLHttpRequest();
xhr.onload = function() {
// 249 is the total number of countries
callback(JSON.parse(xhr.responseText), 249);
const response = JSON.parse(xhr.responseText);
callback(response.result, response.size);
};
var index = params.page * params.pageSize;
xhr.open('GET', 'https://demo.vaadin.com/demo-data/1.0/countries?index=' + index + '&count=' + params.pageSize, true);
const url = 'https://demo.vaadin.com/demo-data/1.0/people?index=' + index +
'&count=' + params.pageSize +
'&filters[lastName]=' + params.filter;
xhr.open('GET', url, true);
xhr.send();
};
});
Expand Down

0 comments on commit db2d902

Please sign in to comment.