JQuery JSTree Plugin

1469
9
12-06-2019 07:49 AM
LaurynasGedminas2
Regular Contributor

try to use this library in the widget:

GitHub - vakata/jstree: jquery tree plugin 

Getting error on the jstree is not a function.

the library is referenced int he index.html

<!-- JStree -->
<script src="//cdnjs.cloudflare.com/ajax/libs/jquery/3.1.1/jquery.min.js"></script>
<link rel="stylesheet" href="https://community.esri.com//cdnjs.cloudflare.com/ajax/libs/jstree/3.3.8/themes/default/style.min.css" />
<script src="//cdnjs.cloudflare.com/ajax/libs/jstree/3.3.8/jstree.min.js"></script>

How to resolve this?

Thank you,

Tags (1)
0 Kudos
9 Replies
LaurynasGedminas2
Regular Contributor

I tired all these methods neither worked.

Putting it in the widget it self would stall widget load:

 'jimu/loaderplugins/jquery-loader!https://cdnjs.cloudflare.com/ajax/libs/jstree/3.3.8/jstree.min.js',

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Laurynas,

   You can not use the jquery-loader to add a script like the jstree.min.js. Also you will not be able to use a cdn when adding trying to add the lib to the widget folder as method three recommends. What method 3 is saying is you add the actual *.js file to the widgets folder and then decalre it in the widget define array.

0 Kudos
LaurynasGedminas2
Regular Contributor

that get me further,loading thru jstree.js into widget. Getting error:

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Now jQuery library does have to loaded using jquery-loader

0 Kudos
LaurynasGedminas2
Regular Contributor

Ye, its loaded. still giving this error:

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Can you get jQuery to load properly if you comment out the jstree portion of the define?

0 Kudos
LaurynasGedminas2
Regular Contributor

JQuery loads properly if i comment out the jstree on the define.

Looks like the jstree has Jquery global already:

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

So you will have to require the jstree module in your widget after you know jQuery is loaded then. So in the widgets onOpen method you can add the jstree require.

0 Kudos