Javascript 按ctrl键时选择2个ajax搜索激发

Javascript 按ctrl键时选择2个ajax搜索激发,javascript,jquery,select,Javascript,Jquery,Select,我有以下选择2字段: $("select#edit-property-id").select2({ multiple: false, width: 150, delay: 250, placeholder: "Type", minimumInputLength: 1, ajax: {// instead of writing the function to execute the request we use Select2's // convenient help

我有以下选择2字段:

$("select#edit-property-id").select2({
  multiple: false,
  width: 150,
  delay: 250,
  placeholder: "Type",
  minimumInputLength: 1,
  ajax: {// instead of writing the function to execute the request we use Select2's 
  // convenient helper  
    url: "/tell/product_chosen_search",
    dataType: 'json',
    data: function (params) {
      return {
        term: params.term, // search term
      };
    },
    processResults: function (data, page) {
      return {
        results: data
      };
    },
  },
});

当我输入字符时,ajax搜索会正确启动,但当我按下ctrl、down按钮等键时,它也会启动。。。我怎样才能防止呢?是否有设置?

这似乎是Select2的新4.0版本中的一个缺陷,该版本仍处于测试阶段

在v3.5.2中,
updateResults
函数中的以下行可防止不必要的ajax调用:

// prevent duplicate queries against the same term
if (initial !== true && lastTerm && equal(term, lastTerm)) return;


这是一个例子。至少,我认为这两个问题可以同时解决。您可能需要为该问题添加注释。

您需要
openOnEnter:false
,请参阅票证