【问题标题】:how to retain Select2 results after select?选择后如何保留Select2结果?
【发布时间】:2014-06-01 23:22:27
【问题描述】:

例如,当使用select2 muti-value时,用户输入'new',并显示

  • 新墨西哥
  • 新罕布什尔州
  • 新泽西
  • 纽约

选择“New Mexcio”后,用户想从剩余的 3 个中再次选择。为此,用户必须再次输入“新”。

有没有办法保留结果而不是清除'查询?

谢谢

【问题讨论】:

    标签: javascript jquery-select2


    【解决方案1】:

    听起来您想将查询从一个搜索保留到下一个搜索。您可能想查看nextSearchTerm 属性。

    要在下一次搜索中显示当前值,

    function displayCurrentValue(selectedObject, currentSearchTerm) {
      return currentSearchTerm;
    }
    
    $("#e1").select2({
      nextSearchTerm: displayCurrentValue
    });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-07-19
      • 1970-01-01
      • 2013-04-02
      • 1970-01-01
      • 1970-01-01
      • 2015-10-15
      相关资源
      最近更新 更多