gpt4 book ai didi

javascript - jQuery UI 可排序项目不起作用

转载 作者:行者123 更新时间:2023-11-30 17:47:58 24 4
gpt4 key购买 nike

我正在尝试使用 jQuery UI 创建一个包含可排序行的表格。我已经有了这个工作,但我打算只根据复选框对某些行(而不是所有行)进行排序。

我把代码上传到http://jsfiddle.net/detesto/7Tcgc/3/

当复选框更改时,我添加或删除应触发可排序行的类。问题是当它被移除时,它不会按预期工作。

我还尝试对 sortble $("#selector").sortable("refresh"); 进行刷新,但这对我也不起作用。

如果用户拖动无效行,我会通过取消事件来实现它,但我想完全避免这种情况。

这可以预防吗?

提前致谢。

最佳答案

更改此代码

$(document).ready(function () {
clearTimeout(timeoutOnce);
timeoutOnce = setTimeout(reorderRows, 300);
$("#fileTable tbody").sortable({
helper: fixHelper,
items: "> tr.doSort",
cancel: ".noSort" //---- add
}).disableSelection();
}).on("click", ".enableDisable", function () {
if ($(this).is(":checked")) {
$(this).closest("tr").removeClass("noSort").addClass("doSort");
//$("#fileTable tbody").sortable("refresh"); // --- remove
} else {
$(this).closest("tr").addClass("noSort").removeClass("doSort");
//$("#fileTable tbody").sortable("refresh"); // --- remove
}
});

关于javascript - jQuery UI 可排序项目不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19718937/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com