Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I had a similar problem a couple of weeks ago. I had a function call in the "url" field, which ultimately led to java code that made a JSON string based on a SQL query. So when I clicked on a childless closed node, the function was called again, resulting in an endless tree.</p> <p>the way I solved this was:</p> <pre><code>"json_data" : { "ajax" : { "url" : "getAreaTree?treeType=Areas&amp;ownerPhone=&lt;%=webSessionObject.getUserPhoneNum()%&gt;", "data" : function (n) { return { id : n.attr ? n.attr("id") : 0 }; } } }, </code></pre> <p>The result of the function defined in "data" will be added as a parameter to the "url" function. Then I can check whether the parameter was 0 (initial load) or 1 (the id of my root) or something else.</p> <p>If this doesn't work for you, maybe you could try something like this:</p> <pre><code>.bind("before.jstree",function(event,data){ if(data.func === "create"){ var foo = true; data.inst._get_node(null, true).each(function () { if(this.id!=rootId &amp;&amp; this.id!=0){ foo = false; }) if(!foo){ event.stopImmediatePropagation(); return false; } } }) </code></pre> <p>I'm not exactly sure this works though. "before.jstree" fires before all events. I'm checking whether the function about to fire is "create", and if it is I check the id of the selected node. If it's something else than my root's id or 0 (initial load) I stop the create function.</p> <p>I use a similar structure for a different situation, so something like this should work. It could be that the "create" event is not what you should be binding to though. You can change it to</p> <pre><code>.bind("before.jstree",function(event,data){ console.log(data.func) if(data.func === "create"){ </code></pre> <p>To see which functions are called.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload