【发布时间】:2012-07-13 07:42:40
【问题描述】:
我想在 HTML 表中从数据库中输出一些数据,并且我希望用户能够重新排序表行。为此,我使用了可排序的 jQuery UI,因此:
<script>
$(function() {
$( "#sortable" ).sortable();
$( "#sortable" ).disableSelection();
});
</script>
<?php
while($row = mysql_fetch_assoc($co_authors)) {
echo "<tr id='sortable'><td>{$row['author_email']}</td>
<td>{$row['coauthor_level']}</td>";
<td><button class='remove' id='remove' name='remove' email="<?php echo $row['author_email'] ?>"
paper="<?php echo $row['paper_id'] ?>">Remove</button></td>
</tr>";
}
?>
问题是当我拖动表格tr时,只有td被拖动。此外,最重要的是,只有第一行是可拖动的:效果不会应用于其他行。我该如何解决这个问题?
【问题讨论】:
-
id属性在文档中必须是唯一的。您的代码正在创建多个具有相同id(sortable) 的元素。尝试改用class。 -
对于它的价值 -
tds 与contenteditable属性似乎不可编辑,如果他们的行可以使用这种方法进行排序。仅供参考。
标签: jquery jquery-ui html-table jquery-ui-sortable