vakata / jstree

jquery tree plugin
http://jstree.com
MIT License
5.15k stars 1.38k forks source link

Calling jstree from a sourced .js file #2496

Closed generalpsycha closed 3 years ago

generalpsycha commented 3 years ago

Hi, first of all thank you for this library! I want to include it in my Electron app, so I followed your tutorial and managed to get it to work.

But now I have a problem. I'm trying to get access to the jstree method from a .js file. I mean, when I do it like in the tutorial: <script> code </script> it works fine. But when I do <script src="functions.js"> I get an error that "jstree is not a function"

Apparently, the functions.js script doesn't see the library. Do you know how to access it from a file?

Also, I have just a little suggestion. I wonder if you could update in your tutorial the usage of jstree with Electron, since it requires a different approach to JQuery, otherwise there are errors that JQuery is undefined. First the user has to install jquery package in the project: npm install jquery --save

Then, in the html, instead of: <script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>

Has to do:

Thank you!

generalpsycha commented 3 years ago

Hello, it worked from the start, just that I wasn't calling it properly, since I didn't require jQuery in my .js file.

However, the second part of my question, the suggestion to add steps for Electron, remains.

vakata commented 3 years ago

I am glad you found the problem. I use electron too, unfortunately it is not practical to include docs for various platforms. It is best to know how your platform dependency management works (amd, umd, etc)