jsTree:从应用程序目录加载jquery.jstree.js文件的行为与从URL加载文件的行为不同 [英] jsTree: loading the jquery.jstree.js file from an app dir behaves differently from loading it from a URL

查看:143
本文介绍了jsTree:从应用程序目录加载jquery.jstree.js文件的行为与从URL加载文件的行为不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我确定这很简单,但这确实让我感到困惑.不幸的是,我对jsTree/jQuery非常陌生,对javascript也非常陌生.基于jsTree文档页面中的示例,我的Web应用程序中有一棵起作用的树.该树功能正常,看起来不错,并且发生事件的情况也很好.

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.

问题在于该演示程序使用如下网址加载了jstree javascript库:

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>

昨天我下载了1.0rc2 jsTree zip文件,将其解压缩,然后将jQuery和jstree javascript库放在我的Web应用程序中的适当位置.然后,我将jstree库的加载更改为以下内容:

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>

当我这样做时,树仍然可以工作.根节点仍然显示,并且我必须扩展第一个节点的按钮仍然有效.但是,文件夹图标,扩展三角形和圆点不见了.我知道文件位置正确.如果不是,我会看到错误,并且扩展第一个节点的按钮将不起作用.我还多次复制了此测试,所以我知道行为上的差异是由从我的应用程序的目录而不是从URL加载它引起的.

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.

我明确地从 http://static.jstree下载了js文件. com/v.1.0rc2/jquery.jstree.js ,并与zip发行版中的文件进行了比较,没有任何差异.

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.

由于某种原因使我完全不知所措,从url加载库允许正确显示树,但从我的app文件夹加载完全相同的文件则不然.

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.

有人有什么想法吗?

感谢您的帮助.

推荐答案

您是否解压缩了JSTree随附的CSS文件?

Did you unpack CSS files that come with JSTree?

它试图从主题目录(v.1.0rc2/themes/default/style.css)自动加载它,好像它们在您的服务器上不到位.

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.

检查Firebug NET选项卡,查找CSS的404错误

Check Firebug NET tab, look for 404 errors for CSS

这篇关于jsTree:从应用程序目录加载jquery.jstree.js文件的行为与从URL加载文件的行为不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆