.jstree() 或 .tree(),以及如何让它工作

发布于 2024-09-04 07:46:50 字数 277 浏览 0 评论 0原文

愚蠢的问题。我在网上找到的很多使用 jstree 的示例都使用语法 $('#someTreeId').tree(),而 jstree 网站上的演示一直引用语法 $('#someTreeId').jstree() 。

当我使用 .jstree() 时,我收到浏览器错误,指出这不是一个函数。但是当我使用 .tree 时,我几乎没有取得任何进展:它只能到达“正在加载...”。

到目前为止,我还没有在函数括号内包含任何选项。我假设如果我在 HTML 中包含 UL,jstree 会生成一个基本树。但事实并非如此。

Silly question. A lot of examples using jstree that I find on the web use the syntax $('#someTreeId').tree(), whereas the demo on the jstree website keeps referring to the syntax $('#someTreeId').jstree().

When I use .jstree() I get a browser error saying this is not a function. But when I use .tree I barely get any farther: it only gets to 'Loading...'.

So far I haven't included any options at all inside the function brackets. I was assuming jstree would produce a basic tree if I included the UL in the HTML. But it doesn't.

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

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

发布评论

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

评论(3

笑脸一如从前 2024-09-11 07:46:50

可以使用这个技巧来查找 jstree 插件的确切函数名称。

打开 jquery.jstree.js,检查关键字“$.fn.* =”或“jQuery.fn.* =”或“jQuery.* =”或“$.*=”,

“*”将是函数名称。

不要复杂化,在 jstree 插件中,函数名称是 jstree()。错误不是函数是因为插件未加载。检查jstree.js的脚本路径是否正确。

May be use this trick to find the exact function names of jstree plugin.

Open jquery.jstree.js, check for the keyword "$.fn.* =" or "jQuery.fn.* = " or "jQuery.* =" or "$.*="

The '*' will be the function names.

Not to complicate, in jstree plugin the function name is jstree(). The error not a function is because, the plugin is not loaded. Check if the script path to jstree.js is correct.

┈┾☆殇 2024-09-11 07:46:50

我总是会使用插件网站上的文档而不是第三方的文档。第三方文档可能不是最新的,而插件的网站确实应该是最新的。

我还没有遇到 jstree 抛出“这不是函数”错误的问题。如果对 jstree 的调用失败,那么您的标记将不会被设计为树,这解释了为什么不生成基本树。

至于为什么会出现错误,我首先要检查的是所有必要的 JavaScript 库都被引用并且顺序正确。例如,页面标签中应包含类似以下内容(根据需要调整路径):

<script type="text/javascript" src="js/_lib/jquery.js"></script>
<script type="text/javascript" src="js/jquery.jstree.js"></script>

I would always go with the documentation from the plugin's website rather than a third-party. The third-party documentation may not be up to date whereas the plugin's website really should be.

I haven't come across the issue with jstree throwing a "This is not a function" error. If the call to jstree fails then your markup won't be styled as a tree so that explains why a basic tree isn't produced.

As for why the error comes up, the first thing I would check is that all the necessary JavaScript libraries are referenced and in the correct order. For example, something like the following should be in your page's tag (adjust the paths as required):

<script type="text/javascript" src="js/_lib/jquery.js"></script>
<script type="text/javascript" src="js/jquery.jstree.js"></script>
月寒剑心 2024-09-11 07:46:50

问题

@Scripts.Render("~/bundles/jquery") 

我发现实际上这一行导致了_layout 中的

I found actually this line cause the problem

@Scripts.Render("~/bundles/jquery") 

in _layout

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