问题
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.
回答1:
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
来源:https://stackoverflow.com/questions/4822194/jstree-loading-the-jquery-jstree-js-file-from-an-app-dir-behaves-differently-fr