简体   繁体   English

使用ajax URL进行select2分页

[英]select2 paging using ajax url

I'm using a select2 dropdown box but need to limit the amount of data requested using the paging function to do this. 我使用的是select2下拉框,但需要限制使用分页功能来请求的数据量。 As part of this i want to pass the page into the ajax url like so: 作为此操作的一部分,我想像这样将page传递到ajax url中:

this.$(".select2").select2({
      placeholder: 'None',
      ajax: {
        url: function (params, page) {
            return "/someURL/"+page
        },
        dataType: 'json',
        delay: 250,
        data: function (term, page) {
            return {
                q: term, // search term
                page: page,
            };
        },
        processResults: function (data, page) {
            var more = (page * 10) < data.length;
            udata =[{'id': 0, 'text': 'None'}];
            for (i in data){
                udata.push({'id': data[i]['id'], 'text': data[i]['name']});
            }
          return {results: udata, more: more};
        }
      },
    });

currently the page returns undefined. 当前页面返回未定义。 any ideas? 有任何想法吗?

there was an issue with the official doccumentation; 官方文件存在问题; the processResults return should return processResults返回应该返回

pagination.more: more 

not

more: more

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM