我正在使用 selct2,并且正在使用 ajax 加载一些数据。结果没有限制,但我必须无限滚动。一些想法?
我有一个这样的json
{"len":30,"data":[{"value":"223118","type":1,"name":"Peter","language":3},
{"value":"223118","type":1,"name":"John","language":2},
{"value":"223118","type":2,"name":"Mike","language":1},
{"value":"223118","type":1,"name":"George","language":3}
....
]}
我正在使用标准的 select2 功能进行 ajac 加载:
$( selector ).select2({
placeholder: "Search",
minimumInputLength: 1,
id: function(bond){return {id: bond._id};},
ajax: {
//url: $("#area-of-operating_0").attr('data-url'),
url: 'myurl',
dataType: 'json',
quietMillis: 100,
data: function (term, page) {
return {
page_limit: 10, // page size
page: page // page number
//q: term
};
},
results: function (data, page) {
var more = (page * 10) < data.total;
return {results: data.data, more: more}
}
},
formatResult: selectFormatResult, // see example
formatSelection: selectFormatSelection
})
问题是 json 可以包含 1000 个元素。我想用 10 个元素制作无限滚动