의 도움을하시기 바랍니다 :
$("#divtree").jstree({
"plugins": ["themes", "html_data", "ui", "crrm", "contextmenu"],
"contextmenu": {
"items": function ($node) {
return {
"Create": {
"label": "Create a new employee",
"action": function (obj) {
this.create(obj);
}
},
"Rename": {
"label": "Rename an employee",
"action": function (obj) {
this.rename(obj);
}
},
"Delete": {
"label": "Delete an employee",
"action": function (obj) {
this.remove(obj);
}
}
};
}
}
});
좋아,이 예제에서 나는 단지 클릭 핸들러 내부의 기본 기능을 호출 오전 : this.create(obj);
, this.rename(obj);
및 this.remove(obj);
obj
을 클릭 된 노드가됩니다.
이제 예를 들어, 당신은 새로운 항목이 jsTree 문서의 demo page
에서와 같이이 create.jstree
이벤트를 구독 할 수 있습니다 추가 될 때 서버에 AJAX 요청을 보내려면 :
<script type="text/javascript">
$("#divtree").jstree({
"plugins": ["themes", "html_data", "ui", "crrm", "contextmenu"],
"contextmenu": {
"items": function ($node) {
return {
"Create": {
"label": "Create a new employee",
"action": function (obj) {
this.create(obj);
}
},
"Rename": {
"label": "Rename an employee",
"action": function (obj) {
this.rename(obj);
}
},
"Delete": {
"label": "Delete an employee",
"action": function (obj) {
this.remove(obj);
}
}
};
}
}
})
.bind("create.jstree", function (e, data) {
$.ajax({
url: "@Url.Action("create", "employees")",
type: 'POST',
data: {
"name" : data.rslt.name
},
success: function (result) {
}
});
});
</script>
검사 create.jstree
이벤트 콜백으로 전달되는 e
및 data
인수 여기에는 AJAX 요청과 함께 보낼 수있는 새로 생성 된 노드에 대한 유용한 정보가 많이 포함되어 있습니다.
이 예제에서 영감을 얻어 문서에 표시된대로 remove.jstree
및 rename.jstree
이벤트로 계속 확장 할 수 있습니다. 그래서 당신이 그것을 볼 때, 필요한 모든 것은 문서를 읽는 것이 었습니다. 예를 들어 필자는 평생 jsTree를 사용한 적이 없지만 문서에서 예제를 찾고 빠른 스파이크를 수행하는 데 5 분이 걸렸습니다. 다음 번에 당신이 사용하고있는 플러그인이나 프레임 워크에 대한 프로그래밍 관련 질문이 있으면 먼저 문서를 읽는 데 더 많은 노력을 기울이십시오.
예, 가능합니다. [무엇을 시도 했습니까?] (http://mattgemmell.com/2008/12/08/what-have-you-tried/) 질문은 무엇입니까? –
가 미안 해요, 난 내가 트 리뷰, 물론 를 사용하여 처음입니다, –