我有一个表,我使用jQuery UI的sortable函数对其主体进行了排序。在这个可排序的表中,我有一个文本区域,允许用户输入关于给定表项的注释。
<table id="status">
<thead>
<tr>
<th>Name</th>
<th>Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td class="dragHandle">Jason</td>
<td><textarea class="commentBox"></textarea></td>
</tr>
</tbody>
</table>
以及使表可排序的javascript(还有一个用于使表可排序的helper函数,我在网上找到)
// Return a helper with preserved width of cells
var fixHelper = function(e, ui) {
ui.children().each(function() {
$(this).width($(this).width());
});
return ui;
};
$("#status").sortable({
helper: fixHelper,
axis: 'y',
handle: '.dragHandle'
}).disableSelection();
进入这个文本区域的文本输入工作正常,但是当我尝试在文本区域中选择文本时,什么都不会发生。即使使用Shift+Arrow键也不会像我预期的那样。
如何在使整个表可排序的同时使文本区域的文本可选择?
已尝试:
-
当一个文本区域获得焦点并暂时允许可选择时,在表上执行可排序的“销毁”,但是即使在销毁之后,文本选择仍然是不稳定的。
-
将可排序的“handle”属性设置为仅使名称字段可排序
-
将可排序的“disable”属性设置为从文本区域启动时禁用
-
捕获文本区域(或包含文本区域的div)中的mousedown/mouseup事件并调用事件停止传播()