完全な例については、JSBinを参照してください。要するに
、あなたはS generateRequest()
方法iron-scroll-treshold
「あなたはiron-ajax
呼び出すのon-lower-threshold
かon-upper-threshold
イベントを、」処理する必要があります。また、iron-ajax
のon-response
イベントで新しいアイテムを処理する必要があります。
コード:
<dom-module id="test-app">
<template>
<iron-ajax id="ajax"
url="https://randomuser.me/api/"
handle-as="json"
params='{"results": 20}'
on-response="categoriesLoaded">
</iron-ajax>
<iron-scroll-threshold on-lower-threshold="loadMoreData" id="threshold">
<iron-list id="list" items="[[categoriesJobs]]" as="person" scroll-target="threshold">
<template>
<!-- item template -->
</template>
</iron-list>
</iron-scroll-threshold>
</template>
<script>
Polymer({
is: 'test-app',
attached: function() {
this.categoriesJobs = [];
},
loadMoreData: function() {
console.log('load more data');
this.$.ajax.generateRequest();
},
categoriesLoaded: function (e) {
var self = this;
var people = e.detail.response.results;
people.forEach(function(element) {
self.push('categoriesJobs', element);
});
this.$.threshold.clearTriggers();
}
});
</script>
</dom-module>
NOTE
iron-list
とiron-scroll-threshold
に関連した質問にanswer私の前の1に基づく例。
最初のloadMoreDataによって理由があるのは、3つの要素しかレンダリングされませんか? 後続のloadMoreDataは、さらに多くの要素をレンダリングします。 –
バグがありますが...私はそれを修正しようとしています。私はそれが完了したらあなたに通知します。 – Hunex
@AtipAsvanundこれは回避策に過ぎず、JSBinをもう一度チェックアウトして、 'categoriesLoaded'関数を編集しました。最初の20項目を読み込むときに、 'iron-list'の' notifyResize() '関数を呼び出します。 – Hunex