Jstree의 트리구조 접기/펼치기 기능에 대해서(재질문) 정보
Jstree의 트리구조 접기/펼치기 기능에 대해서(재질문)관련링크
첨부파일
본문
Jstree 프로그램을 보수 중에 있습니다.
원래는 다른 사람이 만든 것을 보수하다가 다음과 같은 문제가 발생하여 고수분들께 자문을 구합니다.
문제는 트리구조에서 접기/펴기 기능이 작동하지 않습니다. 원 개발자는 linux환경에서 개발을 하였는데 자기 서버에서는 접기 펴기 기능이 잘 된다고 하던데 이상하게 제 홈페이지에서는 이 기능이 안되고 있습니다. 제 pc인 windows xp로서 pc 환경 문제 인지 아니면 해당 코드가 완벽하지 않아서 인지 그 이유를 모르겠습니다.
아래 그림을 참조하시고(관련 홈페이지는 www.biz-nara.com 메뉴 "프로필>특기과목관리" 입니다.
관련 코드는 major_tree.php내에
//html 부분;
<!-- 트리 시작 -->
<div id="major_tree" class="major" style="height:500px;border:1px solid #8c8cff;overflow:scroll;">
<ul>
<?
//$open_tree = "";
load_major(0, $gr);
function load_major($mj_id, $gr)
{
global $open_tree;
$sql = "select * from major_list where type = '$gr' and p_id = $mj_id ";
$result = sql_query($sql);
for( $i = 0; $row = sql_fetch_array($result); $i++ )
{
//$open_tree .= "\"$row[mj_id]\", ";
echo "<li id='{$row[mj_id]}'><a href='#'>{$row[mj_name]}</a>";
echo "<ul>";
load_major($row[mj_id], $gr); echo "</ul>\n</li>\n";
}
}
//$open_tree .= "\"\"";
?>
</ul>
</div>
//Javascript 함수(Jquery)로는 ;
$(function () {
// TO CREATE AN INSTANCE
// select the tree container using jQuery
$("#major_tree")
// call `.jstree` with the options object
.jstree({
"themes" : {
"theme" : "classic",
"dots" : true
},
// the `plugins` array allows you to configure the active plugins on this instance
"plugins" : ["themes","html_data","ui","crrm","hotkeys", "search"]
// each plugin you have included can have its own config object
//, "core" : { "initially_open" : [ <?=$open_tree?> ] }
// it makes sense to configure a plugin only if overriding the defaults
})
// EVENTS
// each instance triggers its own events - to process those listen on the container
// all events are in the `.jstree` namespace
// so listen for `function_name`.`jstree` - you can function names from the docs
.bind("loaded.jstree", function (event, data) {
// you get two params - event & data - check the core docs for a detailed description
})
// 노드 클릭시 이벤트 핸들러
// 1) if using the UI plugin bind to select_node
.bind("select_node.jstree", function (event, data) {
// `data.rslt.obj` is the jquery extended node that was clicked
//alert(data.rslt.obj.attr("id"));
select_id(data.rslt.obj.attr("id"));
})
// 2) if not using the UI plugin - the Anchor tags work as expected
// so if the anchor has a HREF attirbute - the page will be changed
// you can actually prevent the default, etc (normal jquery usage)
.delegate("a", "click", function (event, data) { event.preventDefault(); });
// INSTANCES
// 1) you can call most functions just by selecting the container and calling `.jstree("func",`
//setTimeout(function () { $("#major_tree").jstree("set_focus"); }, 500);
// with the methods below you can call even private functions (prefixed with `_`)
// 2) you can get the focused instance using `$.jstree._focused()`.
//setTimeout(function () { $.jstree._focused().select_node("#major_root"); }, 1000);
// 3) you can use $.jstree._reference - just pass the container, a node inside it, or a selector
//setTimeout(function () { $.jstree._reference("#major_root").close_node("#major_root"); }, 1500);
// 4) when you are working with an event you can use a shortcut
//$("#major_root").bind("open_node.jstree", function (e, data) {
// data.inst is the instance which triggered this event
// data.inst.select_node("#phtml_2", true);
//});
setTimeout(function () { $.jstree._reference("#major_tree").open_node("#major_tree"); }, 1000);
});
며칠을 삽질하고 있지만 해결을 못하고 있습니다. 도와주세요.
부탁하는 김에 조금 더,
탭항목을 클릭하면 탭항목 옆에 붙여놓은 '검색 input box' 와 style이 모두 사라지는데 그 이유는요?
그나저나 변수 $open_tree가 갑자기 나타났는데 이건 어디서 생긴거고 그 내용이 무엇인지요?
원래는 다른 사람이 만든 것을 보수하다가 다음과 같은 문제가 발생하여 고수분들께 자문을 구합니다.
문제는 트리구조에서 접기/펴기 기능이 작동하지 않습니다. 원 개발자는 linux환경에서 개발을 하였는데 자기 서버에서는 접기 펴기 기능이 잘 된다고 하던데 이상하게 제 홈페이지에서는 이 기능이 안되고 있습니다. 제 pc인 windows xp로서 pc 환경 문제 인지 아니면 해당 코드가 완벽하지 않아서 인지 그 이유를 모르겠습니다.
아래 그림을 참조하시고(관련 홈페이지는 www.biz-nara.com 메뉴 "프로필>특기과목관리" 입니다.
관련 코드는 major_tree.php내에
//html 부분;
<!-- 트리 시작 -->
<div id="major_tree" class="major" style="height:500px;border:1px solid #8c8cff;overflow:scroll;">
<ul>
<?
//$open_tree = "";
load_major(0, $gr);
function load_major($mj_id, $gr)
{
global $open_tree;
$sql = "select * from major_list where type = '$gr' and p_id = $mj_id ";
$result = sql_query($sql);
for( $i = 0; $row = sql_fetch_array($result); $i++ )
{
//$open_tree .= "\"$row[mj_id]\", ";
echo "<li id='{$row[mj_id]}'><a href='#'>{$row[mj_name]}</a>";
echo "<ul>";
load_major($row[mj_id], $gr); echo "</ul>\n</li>\n";
}
}
//$open_tree .= "\"\"";
?>
</ul>
</div>
//Javascript 함수(Jquery)로는 ;
$(function () {
// TO CREATE AN INSTANCE
// select the tree container using jQuery
$("#major_tree")
// call `.jstree` with the options object
.jstree({
"themes" : {
"theme" : "classic",
"dots" : true
},
// the `plugins` array allows you to configure the active plugins on this instance
"plugins" : ["themes","html_data","ui","crrm","hotkeys", "search"]
// each plugin you have included can have its own config object
//, "core" : { "initially_open" : [ <?=$open_tree?> ] }
// it makes sense to configure a plugin only if overriding the defaults
})
// EVENTS
// each instance triggers its own events - to process those listen on the container
// all events are in the `.jstree` namespace
// so listen for `function_name`.`jstree` - you can function names from the docs
.bind("loaded.jstree", function (event, data) {
// you get two params - event & data - check the core docs for a detailed description
})
// 노드 클릭시 이벤트 핸들러
// 1) if using the UI plugin bind to select_node
.bind("select_node.jstree", function (event, data) {
// `data.rslt.obj` is the jquery extended node that was clicked
//alert(data.rslt.obj.attr("id"));
select_id(data.rslt.obj.attr("id"));
})
// 2) if not using the UI plugin - the Anchor tags work as expected
// so if the anchor has a HREF attirbute - the page will be changed
// you can actually prevent the default, etc (normal jquery usage)
.delegate("a", "click", function (event, data) { event.preventDefault(); });
// INSTANCES
// 1) you can call most functions just by selecting the container and calling `.jstree("func",`
//setTimeout(function () { $("#major_tree").jstree("set_focus"); }, 500);
// with the methods below you can call even private functions (prefixed with `_`)
// 2) you can get the focused instance using `$.jstree._focused()`.
//setTimeout(function () { $.jstree._focused().select_node("#major_root"); }, 1000);
// 3) you can use $.jstree._reference - just pass the container, a node inside it, or a selector
//setTimeout(function () { $.jstree._reference("#major_root").close_node("#major_root"); }, 1500);
// 4) when you are working with an event you can use a shortcut
//$("#major_root").bind("open_node.jstree", function (e, data) {
// data.inst is the instance which triggered this event
// data.inst.select_node("#phtml_2", true);
//});
setTimeout(function () { $.jstree._reference("#major_tree").open_node("#major_tree"); }, 1000);
});
며칠을 삽질하고 있지만 해결을 못하고 있습니다. 도와주세요.
부탁하는 김에 조금 더,
탭항목을 클릭하면 탭항목 옆에 붙여놓은 '검색 input box' 와 style이 모두 사라지는데 그 이유는요?
그나저나 변수 $open_tree가 갑자기 나타났는데 이건 어디서 생긴거고 그 내용이 무엇인지요?
댓글 전체

도움이 될지는 모르겠지만...
jstree는, 시스템이나 운영체제 문제라기 보다는, 브라우져 특성을 타는 것 같네요.
구글 크롬에서는 정상적으로 작동하는 데, 익스에서는 문제가 있어 보입니다..
크롬에서 문제가 있으면 해결하기가 쉬운데.. 익스에서 문제가 발생하면 찾기가 쉽지가 않아서..-_-
검색 input box는 사라지는 문제는,
input box가 들어있는 코드 (major_tree.php)와 탭에 연결되어 있는 코드 (list.php)가 다르고,
list.php에는 input box가 들어있지 않은것 같습니다.
$open_tree는... 글쎄요.. 원래 코딩한 사람의 의도를 다른 사람이 알수는 없지 않을까 합니다. .^^;
jstree는, 시스템이나 운영체제 문제라기 보다는, 브라우져 특성을 타는 것 같네요.
구글 크롬에서는 정상적으로 작동하는 데, 익스에서는 문제가 있어 보입니다..
크롬에서 문제가 있으면 해결하기가 쉬운데.. 익스에서 문제가 발생하면 찾기가 쉽지가 않아서..-_-
검색 input box는 사라지는 문제는,
input box가 들어있는 코드 (major_tree.php)와 탭에 연결되어 있는 코드 (list.php)가 다르고,
list.php에는 input box가 들어있지 않은것 같습니다.
$open_tree는... 글쎄요.. 원래 코딩한 사람의 의도를 다른 사람이 알수는 없지 않을까 합니다. .^^;
번번이 "전진"님의 도움을 많이 받네요.
jstree가 IE에서 문제가 있는 건 맞는것 같습니다. 어느분의 블로글에서 그걸 지적했네요.
http://withdev.tistory.com/58
그런데 그걸가지고 또 어찌해야 할지 참.
input box살아지는 건 알려 주신대로 링크화일 오류이네요. list.php에서 major_tree.php로 고쳐놓고는 해당 링크를 변경하지 않았던 거 군요.
jstree가 IE에서 문제가 있는 건 맞는것 같습니다. 어느분의 블로글에서 그걸 지적했네요.
http://withdev.tistory.com/58
그런데 그걸가지고 또 어찌해야 할지 참.
input box살아지는 건 알려 주신대로 링크화일 오류이네요. list.php에서 major_tree.php로 고쳐놓고는 해당 링크를 변경하지 않았던 거 군요.
Jstree.com 사용자 그룹에 들어가니 Jquery old version의 bug라 해서 최신 버젼 Jquery-1_7_2.js를 깔아 Jquery.js를 update하는 등 할 건 다 해봤는데 여전히 안되네 참.
Jstree를 버려야 하나?
Jstree를 버려야 하나?
드디어 답을 찾았습니다.
head.sub.php내에 있는 header 내용에서 다음을 고치니까 딱 되네요.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3c.org/TR/xhtml1/DTD/xhtml-strict.DTD">
<html xmlns="http://www.w3c.org/1999/xhtml">
어느분의 안내로 이것을 추가해 넣었지만, 이것만으로는 요지부동이다가 다음을 바꾸니 통과
<!-- 변경전
<meta http-equiv="content-type" content="text/html; charset=<?=$g4['charset']?>">
2012.07.17 jstree가 ie에서 잘 안되는 버그 수정
변경 후-->
<meta http-equiv="X-UA-Compatible" content="IE=edge; charset=<?=$g4['charset']?>"/>
이유는 저도 모르겠음. 암튼 Jstree는 확 패버리고 싶지만 버리지 않고 그대로 쓰기로
head.sub.php내에 있는 header 내용에서 다음을 고치니까 딱 되네요.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3c.org/TR/xhtml1/DTD/xhtml-strict.DTD">
<html xmlns="http://www.w3c.org/1999/xhtml">
어느분의 안내로 이것을 추가해 넣었지만, 이것만으로는 요지부동이다가 다음을 바꾸니 통과
<!-- 변경전
<meta http-equiv="content-type" content="text/html; charset=<?=$g4['charset']?>">
2012.07.17 jstree가 ie에서 잘 안되는 버그 수정
변경 후-->
<meta http-equiv="X-UA-Compatible" content="IE=edge; charset=<?=$g4['charset']?>"/>
이유는 저도 모르겠음. 암튼 Jstree는 확 패버리고 싶지만 버리지 않고 그대로 쓰기로