我有一张表,它的列是可编辑的。当我使用this JSFiddle中的示例来使表格中的行可拖动时。
contenteditable属性不起作用。这是my JS Fiddle
如果您注释掉javascript,您可以看到列year是可编辑的,但是如果您想添加javascript以使行可拖动,那么year列是不可编辑的,尽管属性"contenteditible = 'true‘在页面源代码中。
下面是我的html以供参考:
<script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>
<table id="sort" class="grid" title="Kurt Vonnegut novels">
<tbody>
<tr><td class="InputBox_RowClass">1</td><td><p contenteditable='true'>1969</p></td><td>Slaughterhouse-Five</td><td>A+</td></tr>
<tr><td class="InputBox_RowClass">2</td><td><p contenteditable='true'>1952</p></td><td>Player Piano</td><td>B</td></tr>
<tr><td class="InputBox_RowClass">3</td><td><p contenteditable='true'>1963</p></td><td>Cat's Cradle</td><td>A+</td></tr>
<tr><td class="InputBox_RowClass">4</td><td><p contenteditable='true'>1973</p></td><td>Breakfast of Champions</td><td>C</td></tr>
<tr><td class="InputBox_RowClass">5</td><td><p contenteditable='true'>1965</p></td><td>God Bless You, Mr. Rosewater</td><td>A</td></tr>
</tbody>
jQuery:
var fixHelperModified = function(e, tr) {
var $originals = tr.children();
var $helper = tr.clone();
$helper.children().each(function(index) {
$(this).width($originals.eq(index).width())
});
return $helper;
};
$("#sort tbody").sortable({
helper: fixHelperModified
}).disableSelection();
https://stackoverflow.com/questions/50649242
复制相似问题