jstreeでツリーを作成しています。
ノードをクリックすると.on("select_node.jstree", function(e, data){で取得したidからlocation.hrefで別ページに飛ばしています。
stateを有効にしてツリーの開閉状態の保持をしたいのですが、どうやらselect_nodeの状態が保持されているのか
stateを有効にし、ツリーをクリックするとlocation.hrefが無限に繰り返される状態となってしまいます。
stateのfilter機能のようなものを検索して見つけはしたのですがどうも有効に動いてくれません。
select_nodeの状態保持がlocation.hrefを繰り返し呼んでいるのか、また解決方法についてご教示いただけないでしょうか。
■現状
js
1 var tree = $('#tree1').jstree( 2 {'core' : {'data' : ${json}}, "checkbox" : {three_state : false, whole_node : false, tie_selection : false}, "plugins" : ["wholerow", "checkbox"]} 3 ) 4 .on("select_node.jstree", function(e, data){ 5 if (data.node.id == "new") { 6 location.href = "${f:url('/test/list?filter=new')}"; 7 } else { 8 location.href = "${f:url('/test/list?id=')}" + data.node.id; 9 } 10 });
html
1<div id="tree1" ></div>
json
1[ 2 {"id":"new","parent":"#","text":"にゅー"}, 3 {"id":"1","parent":"#","text":"テスト1"}, 4 {"id":"2","parent":"1","text":"テスト2"} 5]
■ほんとうはこうしたい(stateを有効にしてツリーの開閉状況だけを保持したい)
js
1 var tree = $('#tree1').jstree( 2 {'core' : {'data' : ${folderList}}, "checkbox" : {three_state : false, whole_node : false, tie_selection : false}, "plugins" : ["state", "wholerow", "checkbox"]} 3 ) 4 .on("select_node.jstree", function(e, data){ 5 if (data.node.id == "new") { 6 location.href = "${f:url('/test/list?filter=new')}"; 7 } else { 8 location.href = "${f:url('/test/list?inquiryFolderId=')}" + data.node.id; 9 } 10 });
あなたの回答
tips
プレビュー