jQuery UI Sortables - Empty Table
Can't seem to drag into an empty table
by Jason Butz
HTML
<table class='canSort' border="1">
<thead>
<tr>
<th>Cell 1 Header</th>
<th>Cell 2 Header</th>
</tr>
</thead>
<tbody class='canSort'>
<tr>
<td>Row 1 Cell 1</td>
<td>Row 1 Cell 2</td>
</tr>
<tr>
<td>Row 2 Cell 1</td>
<td>Row 2 Cell 2</td>
</tr>
</tbody>
</table>
<hr>
<table class='canSort' border="1">
<thead>
<tr>
<th>Cell 1 Header</th>
<th>Cell 2 Header</th>
</tr>
</thead>
<tbody class='canSort'>
</tbody>
</table>
CSS
table {
width: 100%;
}
th {
text-align: left;
font-weight: bold;
}
JavaScript
$("table tbody.canSort").sortable({
items: 'tr',
cursor: 'crosshair',
connectWith: 'tbody.canSort',
axis: 'y',
dropOnEmpty: true
});