Hey there! any question in your mind? Ask It Now!.

Popular Categories





click event of li in JQuery using Jstree.

+1 vote
926 views
asked in Programming by vicky (390 points)
I am trying to get click event in li using jstree please see the code

$('#uu').click(function () {
var ref = $('#tree').jstree(true),
    sel = ref.get_selected();

if (!sel.length) {
    alert('thank')
    sel = ref.create_node("#", {"id" : node_count+1, "text" : node_count+1});
    node_count++;
} else
{
    sel = sel[0];
    sel = ref.create_node(sel, {"id" : node_count+1, "text" : node_count+1});
    node_count++;
}
/*if (sel) {
    ref.edit(sel);
}*/
ref.deselect_all();
});

Here in alert id of click event is not coming please help me out on this.

1 Answer

+2 votes
answered by jack (1,440 points)
selected by vicky
 
Best answer
As here your li is coming dynamically, so you should get id like this , I hope this will help you.

$("#tree").on("click", "li > a", function() {
    var id = $(this).closest("li").attr("id");
    $(this).siblings(".jstree-icon").click();
    alert(id);
});

Related Questions

+1 vote
1 answer 796 views
+4 votes
5 answers 3,139 views
0 votes
2 answers 305 views
+1 vote
2 answers 122 views
+1 vote
2 answers 126 views
+1 vote
1 answer 175 views
+1 vote
1 answer 270 views
+1 vote
2 answers 213 views

Not a Member yet?

Ask to Folks Login

My Account
444 Folks are online
1 members and 443 guest online
Your feedback is highly appreciated