jsTree:从应用程序目录加载 jquery.jstree.js 文件的行为与从 URL 加载它的行为不同
我确信这很简单,但它确实让我感到困惑。不幸的是,我对 jsTree/jQuery 非常陌生,对 javascript 也非常陌生。我的 Web 应用程序中有一个基于 jsTree 文档页面中的示例的功能树。该树功能正常,看起来不错,并且发送给它的事件也运行良好。
问题是演示使用如下 URL 加载 jstree javascript 库:
<script type="text/javascript" src="http://static.jstree.com/v.1.0rc2/jquery.jstree.js"></script>
我昨天下载了 1.0rc2 jsTree zip 文件,将其解压,然后将 jquery 和 jstree javascript 库放在我的 Web 应用程序中的正确位置。然后,我将 jstree 库的加载更改为以下内容:
<script type="text/javascript" src="<%=request.getContextPath()%>/jquery.jstree.js"></script>
当我这样做时,树仍然可以工作。根节点仍然显示,并且我必须展开第一个节点的按钮仍然有效。但是,文件夹图标、扩展三角形和点都消失了。我知道该文件的位置正确。如果不是,我会看到错误,并且展开第一个节点的按钮将不起作用。我还多次重复了这个测试,所以我知道行为的差异是由于从我的应用程序的目录而不是网址加载它造成的。
我明确地从 http://static.jstree.com/v 下载了js文件.1.0rc2/jquery.jstree.js,并与 zip 发行版中的文件进行比较,没有任何差异。
由于某种我完全无法理解的原因,从 url 加载库可以使树正确显示,但从我的应用程序文件夹加载完全相同的文件却不能。
有人有什么想法吗?
感谢您的帮助。
I'm sure this is something simple, but it's really confusing me. Unfortunately, I'm extremely new to jsTree/jQuery and very new to javascript. I have a functioning tree in my web application based from an example in the jsTree documentation page. The tree functions, looks good, and events going to it work well.
The issue is that the demo loads the jstree javascript library with a URL as follows:
<script type="text/javascript" src="http://static.jstree.com/v.1.0rc2/jquery.jstree.js"></script>
I downloaded the 1.0rc2 jsTree zip file yesterday, extracted it, and put the jquery and jstree javascript libraries in the proper place in my web app. I then change the loading of the jstree library to the following:
<script type="text/javascript" src="<%=request.getContextPath()%>/jquery.jstree.js"></script>
When I do this, the tree still works, sort of. The root nodes are still displayed, and a button I have to expand the first node still works. However, the folder icons, expansion triangle, and dots are gone. I know the file is located correctly. If it wasn't, I would see errors and the button to expand the first node wouldn't work. I've also reproduced this test several times so I know the difference in behavior is caused by loading it from my app's dir instead of the url.
I explicitly downloaded the js file from http://static.jstree.com/v.1.0rc2/jquery.jstree.js, and did a file compare with the one from the zip distribution, and there were no differences.
For some reason that completely escapes me, loading the library from the url allows the tree to be displayed properly, but loading the exact same file from my app folder does not.
Does anyone have any ideas?
Thanks for the help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你解压了 JSTree 附带的 CSS 文件吗?
它尝试从主题目录(
v.1.0rc2/themes/default/style.css
)自动加载它,看起来它们不在您的服务器上。检查 Firebug NET 选项卡,查找 CSS 的 404 错误
Did you unpack CSS files that come with JSTree?
It tries to load it automatically from themes dir (
v.1.0rc2/themes/default/style.css
), it looks like they are not in place on your server.Check Firebug NET tab, look for 404 errors for CSS