I have an input type="text"
in a table
. https://jsfiddle.net/L0vx0hck/
$('#myGrid').selectable({
filter: ".dataItemColumn,.dataText",
cancel: null,
distance: 10
});
td {
padding: 5px;
border: 1px solid black
}
.ui-selected {
background-color: lightblue
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<table id="myGrid">
<tr>
<td class="dataItemColumn">
<input class="dataText" type="text" value="focusable" onclick="this.focus()" />
</td>
<td class="dataItemColumn">
<input type="text" class="dataText" value="aa" />
</td>
</tr>
<tr>
<td class="dataItemColumn">
<input type="text" value="focusable" onclick="this.focus()" />
</td>
<td class="dataItemColumn">
<input type="text" value="aa" />
</td>
</tr>
</table>
<input type="text" value="test" />
<table id="myGrid">
<tr>
<td class="dataItemColumn">
<input type="text" class="dataText" value="aa" />
</td>
</tr>
I am making it selectable
$('#myGrid').selectable({
filter: ".dataItemColumn,.dataText",
cancel: null,
distance: 10
});
After this it is not possible to click into an input
to start editing. As a partial workaround I am setting onclick="this.focus()"
on the input
. It is also possible to omit cancel: null
. The first option allows to start editing only on the begging of text and disallows selecting part of text. The other option gives full editing capabilities but disallows starting selection by dragging over a textbox.
So what I need:
- be able to select textboxes (or their containers
td
) by dragging even if dragging starts on a textbox - be able to start editing by clicking to any place of a textbox
Selecting a part of a text with the mouse would be also useful but not necessary.