我想让用户在Select2选择元素之间复制和粘贴选择。
粘贴应该通过设置tokenSeparators来工作。但我无法通过选择元素复制某些内容。 (因为我无法选择当前选择,所以Ctrl-C不会复制任何内容,上下文菜单也不允许复制。)
是否有可能像我没有看到的Select2选项或我必须通过编程处理这个? (我可以绑定到复制事件,并可能在那里写入剪贴板数据。还不确定这是否适用于多个浏览器。)
到目前为止的基本代码:
<select multiple="multiple">
<option>B</option>
<option>C</option>
</select>
js脚本代码:
$("select").select2({
tokenSeparators: [' ']
})
在22.3.16扩展:
按照kevin-brown的建议设置-user-select,选项变为可选。但至少在chrome中,只有当鼠标从左到右选择所有选项时。仍有改进的潜力。
.select2-container .select2-selection--multiple {
-webkit-user-select: all;
-moz-user-select: all;
-ms-user-select: all;
}
(摘自user select in mozilla developper)
尝试in this fiddle(代码段不起作用)