如何从元素中删除 .selectable

how to remove .selectable from element

我在我的一个 table 上使用 jquery selectable,我希望在某些情况下从元素中删除 .selectable

我找到了一个我可以使用的有效解决方案,那就是添加禁用 true 或 false 的选项,并在 if 和 else 语句中使用它。

$( ".standard-table").selectable({
            filter: "tr",
            disabled: false,
            scrollSnapX: 5, // When the selection is that pixels near to the top/bottom edges, start to scroll
            scrollSnapY: 5, // When the selection is that pixels near to the side edges, start to scroll
            scrollAmount: 25, // In pixels
            scrollIntervalTime: 100 // In milliseconds
});

然而,我希望 jquery selectable 消失,这样我就可以通过其他方式与 table 互动。

当我禁用 Jquery selectable 时,它不会像我想要的那样选择 table,但它会阻止我触发 [=29] 上的任何事件=] 当它被禁用时。

我认为我可以在喜欢时从 .standard-table 中删除 .selectable 并在喜欢时放回去,而不是添加禁用选项。

这可能吗?或者有其他解决方法吗?

您可以使用 destroy method:

删除可选
$( ".standard-table" ).selectable( "destroy" );