用鼠标粘贴文本不会触发搜索

Pasting text with the mouse doesn't trigger search

对于 selectize.js 和 ajax 搜索通过鼠标插入文本不会导致搜索

可以在 http://brianreavis.github.io/selectize.js 页面上简单复制。 在 远程源上 — Github 示例:

  1. 专注领域
  2. 删除所选内容
  3. 通过鼠标插入文本任意文本(不是 按 ctrl+v)
  4. 无结果

如何解决?

更新

用于通过jquery bind 方法捕获事件。 Selectize on 方法无法捕获它(错误?)。

$('.selectize').bind('input', function(){
// force selectize to make ajax call and show result  
});

// following code catch nothing
$('.selectize')[0].selectize.on('input', function(){
// force selectize to make ajax call   
});

但无法找到强制选择 ajax 调用的解决方案

您可以在问题页面上找到修复方法 https://github.com/selectize/selectize.js/issues/882

代码

onPaste: function(e) {
        var self = this;
        if (self.isFull() || self.isInputHidden || self.isLocked) {
            e.preventDefault();
        } else {
            // If a regex or string is included, this will split the pasted
            // input and create Items for each separate value
             setTimeout(function() {
                 if (self.settings.splitOn) {
                    var splitInput = $.trim(self.$control_input.val() || '').split(self.settings.splitOn);
                    for (var i = 0, n = splitInput.length; i < n; i++) {
                        self.createItem(splitInput[i]);
                    }
                  }
                  self.onKeyUp(e);
            }, 0);
        }
    },