cant bind select_node.jstree

조회수 2,229회
읽지 않은 첫 메시지로 건너뛰기

Mauricio Garavaglia

읽지 않음,
2010. 10. 6. 오후 7:11:5710. 10. 6.
받는사람 jsTree
Hi, I have a problem trying to bind the click event of the nodes. my
code is the following

tree_data = eval(<%= json_data_from_the_server %>);
$(function() {
$('#tree_container').jstree({
core : { animation : 0} ,
plugins : ['json_data', 'themes'] ,
json_data : tree_data, themes : { url: '/stylesheets/
tree.css'}
});
$('#tree_container').bind("select_node.jstree",
function(e,data) {
var node_id =data.rslt.obj.attr("id");
alert('you selected the node '+node_id);
});
});

but it doesn't work. if I use delegate('a', 'click', function(e)
{ ...}) instead of bind() it seems to work but i can't access the data
object anymore. Im using jstree1.0rc2 with jquery 1.4.2 on Firefox.
Thanx!

Mauricio

CroNiX

읽지 않음,
2010. 10. 6. 오후 8:20:3010. 10. 6.
받는사람 jsTree
try binding it directly like:
$('#tree_container').jstree({
core : { animation : 0} ,
plugins : ['json_data', 'themes'] ,
json_data : tree_data, themes : { url: '/stylesheets/tree.css'}
}).bind("select_node.jstree", function(e,data) {
var node_id =data.rslt.obj.attr("id");
alert('you selected the node '+node_id);
});

On Oct 6, 4:11 pm, Mauricio Garavaglia <mauriciogaravag...@gmail.com>
wrote:

stefa_n

읽지 않음,
2010. 10. 11. 오전 3:18:0010. 10. 11.
받는사람 jsTree
Hi,

I have the exact same problem, but binding directly didn't help.
Mauricio, were you able to solve this already?

stefa_n

읽지 않음,
2010. 10. 9. 오전 6:01:0810. 10. 9.
받는사람 jsTree

I have the exact same problem, but binding it directly didn't
solve it. Mauricio, did it worked in your case?

vakata

읽지 않음,
2010. 10. 12. 오후 5:15:4810. 10. 12.
받는사람 jsTree
Hi,
to bind to the select_node event, the select_node function should be
active on the tree (the UI plugin must be included) as for the first
post - simply add it to the plugins array: ... "themes","ui"]
And all will work.

When using delegate (not using the UI plugin):
.delegate("a", "click", function (e) {
e.target.parentNode.id // this is the ID
});

Kindest regards,
Ivan
전체답장
작성자에게 답글
전달
새 메시지 0개