cant bind select_node.jstree

Showing 1-5 of 5 messages
cant bind select_node.jstree Mauricio Garavaglia 10/6/10 4:11 PM
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
Re: cant bind select_node.jstree CroNiX 10/6/10 5:20 PM
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:
Re: cant bind select_node.jstree stefa_n 10/11/10 12:18 AM
Hi,

I have the exact same problem, but binding directly didn't help.
Mauricio, were you able to solve this already?
Re: cant bind select_node.jstree stefa_n 10/9/10 3:01 AM

I have the exact same problem, but binding it directly didn't
solve it. Mauricio, did it worked in your case?
Re: cant bind select_node.jstree Ivan Bozhanov 10/12/10 2:15 PM
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