Jax
Jax

Reputation: 7130

Make text selectable in a textarea within a jQuery Sortable parent

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 comments 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="commentBox"></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:

Upvotes: 5

Views: 3393

Answers (1)

methodin
methodin

Reputation: 6712

What's the reasoning for using disableSelection? That is the reason your textArea is not getting focus.

Upvotes: 7

Related Questions