避免自动打开单击Kendo Multi Select时

时间:2014-10-10 06:38:48

标签: kendo-ui

如何在单击kendo multiselect auto complete box时禁用自动打开。当我开始输入时,它可能会打开。

1 个答案:

答案 0 :(得分:3)

您应截取open事件,检查输入文本的长度,如果是0,则调用preventDefault。类似的东西:



$("#required").kendoMultiSelect({
  open : function (e) {
    var len = this.input.val().length;
    if (len == 0) {
      e.preventDefault();
    }
  }
})

<link href="http://cdn.kendostatic.com/2014.2.1008/styles/kendo.common.min.css" rel="stylesheet" />
<link href="http://cdn.kendostatic.com/2014.2.1008/styles/kendo.default.min.css" rel="stylesheet" />
<script src="http://cdn.kendostatic.com/2014.2.1008/js/jquery.min.js"></script>
<script src="http://cdn.kendostatic.com/2014.2.1008/js/kendo.all.min.js"></script>

<select id="required" multiple="multiple" data-placeholder="Select attendees...">
  <option>Steven White</option>
  <option>Nancy King</option>
  <option>Nancy Davolio</option>
  <option>Robert Davolio</option>
  <option>Michael Leverling</option>
  <option>Andrew Callahan</option>
  <option>Michael Suyama</option>
  <option selected>Anne King</option>
  <option>Laura Peacock</option>
  <option>Robert Fuller</option>
  <option>Janet White</option>
  <option>Nancy Leverling</option>
  <option>Robert Buchanan</option>
  <option>Margaret Buchanan</option>
  <option selected>Andrew Fuller</option>
  <option>Anne Davolio</option>
  <option>Andrew Suyama</option>
  <option>Nige Buchanan</option>
  <option>Laura Fuller</option>
</select>
&#13;
&#13;
&#13;