JQuery JSTree 加载为打开状态,然后最小化

发布于 2025-01-08 04:15:20 字数 818 浏览 8 评论 0原文

拳头,潜伏多年,希望这篇文章不仅对我有帮助。

所以我有一个使用非常少量的 JavaScript 为我的网站生成的 jstree。理想情况下,我希望页面仅加载并显示 2 个顶部文件夹。

然而,目前页面显示所有文件夹、子文件夹、文件等的名称大约需要 0.5 秒,然后才会切换到正确的视图。树结构中可能有大约 200 个项目

,我添加了一个手动 tree.bind ,它执行“close_all”,并且我还尝试隐藏它最终出现的 DIV。即使我在创建后放置了代码来显示 DIV树,在隐藏自己之前,它仍然显示出一切。

我正在使用 jsTree 1.0-rc3

大家有什么想法吗?

<script type="text/javascript">

(document).ready(function () {
    var tree = $("#sharepointHierarchy");
    tree.bind("loaded.jstree", function (event, data) {
    tree.jstree("close_all");
    });

    $("#sharepointHierarchy").jstree({
        'plugins' : [ "themes", "html_data", "types", "ui" ],
        'core' : {/* core options go here */},
    });
        document.getElementById("sharepointHierarchy").style.display="block";
});
</script>

Fist off, been lurking for years, hopefully this post will be helpful to more than just me.

So I have a jstree that is generated for my site using very a small amount of JavaScript. Ideally, I would like for the page to load and show the 2 top folders only.

However, currently the page displays all of the names of the folders, subfolders, files, etc. for about 0.5 seconds before switching to the proper view. There are probably about 200 items in the tree structure

I added a manual tree.bind which does a "close_all", and I also tried hiding the DIV that it eventually appears in. Even though I put the code to show the DIV after I create the tree, it still shows everything before hiding itself.

I am using jsTree 1.0-rc3

Anyone have any thoughts?

<script type="text/javascript">

(document).ready(function () {
    var tree = $("#sharepointHierarchy");
    tree.bind("loaded.jstree", function (event, data) {
    tree.jstree("close_all");
    });

    $("#sharepointHierarchy").jstree({
        'plugins' : [ "themes", "html_data", "types", "ui" ],
        'core' : {/* core options go here */},
    });
        document.getElementById("sharepointHierarchy").style.display="block";
});
</script>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风柔一江水 2025-01-15 04:15:20

我可以通过将以下代码添加到 function() 的末尾来掩盖这个问题。它相当简单,只是在显示之前给表格一些时间来加载。

setTimeout(function() {
    $("#sharepointDiv").show();
    },1200);

我希望这对其他人也有帮助。

I was able to mask this issue by adding the following code to the end of the function(). It is fairly straight-forward and simply gives the table time to load before showing it.

setTimeout(function() {
    $("#sharepointDiv").show();
    },1200);

I hope this helps someone else also.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文