简体   繁体   English

如何在jsTree中隐藏/着色/禁用不可单击的复选框?

[英]How to hide/shade/disable non-clickable checkboxes in jsTree?

I list files in directories that can be downloaded. 我在目录中列出了可以下载的文件。 I made the checkboxes of objects that I don't want user to be able to download non-clickable. 我选中了我不希望用户能够下载不可点击的对象的复选框。 All directories cannot be downloaded and some of the files. 无法下载所有目录和某些文件。

But I want to hide the checkboxes completely. 但是我想完全隐藏复选框。 It is very confusing that the checkbox is there but cannot be used. 复选框在那里但无法使用非常令人困惑。

My sample code is on jsfiddle 我的示例代码在jsfiddle上

I think you could use load event of the tree and code like that: 我认为您可以使用树的load事件和类似的代码:

$("#tree").bind("loaded.jstree", function (event, data) {
  $(this).find('li[rel!=file]').find('.jstree-checkbox:first').hide();
})

And then invoke jstree. 然后调用jstree。

Basically, there are two quick, CSS methods for hiding the checkbox: 基本上,有两种用于隐藏复选框的快速CSS方法:

  1. Use display:none 使用display:none
  2. Use visibility:hidden 使用visibility:hidden

Here's a fiddle that uses the first for directories and the second for disabled files; 这是一个小提琴 ,将第一个用于目录,第二个用于禁用文件; but it's not that big a deal. 但这没什么大不了的。 The major difference, as you saw, is that the second leaves the empty space. 如您所见,主要区别在于第二个留出了空白。

Also! 也! Important! 重要! The CSS uses the attribute selector and the child selector , neither of which are supported in IE6. CSS使用属性选择器子选择器 ,IE6不支持这两种选择器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM