weixin_33737774 2018-01-30 15:17 采纳率: 0%
浏览 362

select2延迟不起作用

I am using below code to initialise select2 on a select box. But the delay is not working, requests are going to server immediately.

$(".multi_select").select2({
    multiple: true,
    allowClear: true,
    minimumInputLength: 2,
    delay: 5000,
    ajax: {
      url: "/search.json",
      dataType: 'json'
    }
  });

Another problem I am facing is, I am getting abort error on fast typing, that means previous requests are not getting aborted. Yesterday when I added above code, without delay, it was working fine without 'abort' error. Today, it gives abort error, with and without delay along with failure of delay.

I am using v4.0.3 and there is no change in project since yesterday so I don't understand that what happened suddenly.

  • 写回答

1条回答 默认 最新

  • derek5. 2018-01-31 11:08
    关注

    The delay parameter has to be added to ajax section:

    $(".multi_select").select2({
        multiple: true,
        allowClear: true,
        minimumInputLength: 2,
        ajax: {
          url: "/search.json",
          dataType: 'json',
          delay: 5000
        }
    });
    

    See: https://select2.org/data-sources/ajax#rate-limiting-requests

    评论

报告相同问题?

悬赏问题

  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)
  • ¥20 matlab yalmip kkt 双层优化问题
  • ¥15 如何在3D高斯飞溅的渲染的场景中获得一个可控的旋转物体
  • ¥88 实在没有想法,需要个思路
  • ¥15 MATLAB报错输入参数太多
  • ¥15 python中合并修改日期相同的CSV文件并按照修改日期的名字命名文件
  • ¥15 有赏,i卡绘世画不出
  • ¥15 如何用stata画出文献中常见的安慰剂检验图
  • ¥15 c语言链表结构体数据插入