admin管理员组文章数量:1391960
I have a table whose body I've made sortable using jQuery UI's Sortable function. Within this sortable table, I have a textarea which allows the user to enter ments about a given table entry.
<table id="status">
<thead>
<tr>
<th>Name</th>
<th>Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td class="dragHandle">Jason</td>
<td><textarea class="mentBox"></textarea></td>
</tr>
</tbody>
</table>
And the javascript to make the table sortable (with a helper function for making tables sortable I found online)
// 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();
Text entry into this textarea works fine, however when I try to select text within the textarea, nothing happens. Even using Shift+Arrow Keys does not behave as I would expect.
How do I make a textarea's text selectable while still making the entire table sortable?
Already Attempted:
Doing a sortable "destroy" on the table when a textarea gets focus to try and temporarily allow selectability, but even after the destroy, text selection is still wonky.
Setting the 'handle' property of the sortable to make only the Name field sortable
Setting the 'disable' property of the sortable to disable when initiated from textareas
Capturing the mousedown/mouseup events in the textarea (or a div containing the textarea) and calling event.stopPropagation()
I have a table whose body I've made sortable using jQuery UI's Sortable function. Within this sortable table, I have a textarea which allows the user to enter ments about a given table entry.
<table id="status">
<thead>
<tr>
<th>Name</th>
<th>Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td class="dragHandle">Jason</td>
<td><textarea class="mentBox"></textarea></td>
</tr>
</tbody>
</table>
And the javascript to make the table sortable (with a helper function for making tables sortable I found online)
// 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();
Text entry into this textarea works fine, however when I try to select text within the textarea, nothing happens. Even using Shift+Arrow Keys does not behave as I would expect.
How do I make a textarea's text selectable while still making the entire table sortable?
Already Attempted:
Doing a sortable "destroy" on the table when a textarea gets focus to try and temporarily allow selectability, but even after the destroy, text selection is still wonky.
Setting the 'handle' property of the sortable to make only the Name field sortable
Setting the 'disable' property of the sortable to disable when initiated from textareas
Capturing the mousedown/mouseup events in the textarea (or a div containing the textarea) and calling event.stopPropagation()
- Can you post your sortable JS? – methodin Commented Oct 8, 2010 at 17:46
1 Answer
Reset to default 7What's the reasoning for using disableSelection? That is the reason your textArea is not getting focus.
本文标签: javascriptMake text selectable in a textarea within a jQuery Sortable parentStack Overflow
版权声明:本文标题:javascript - Make text selectable in a textarea within a jQuery Sortable parent - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744740725a2622591.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论