views:

2046

answers:

2

Hello -

I am using the JQuery Treeview plugin to display some data. Basically, I would like to add a click event to the child < li > elements that copies their innerhtml into another div on the page. I have not been able to assign a click event to these < li > elements however.

Hoping someone has tread this ground before and can provide some help.

Thanks.

+2  A: 

Using the markup from the example at http://docs.jquery.com/Plugins/Treeview:

$("span.file, span.folder", "#example li")
    .click(function() { alert($(this).text()); });

works. Handling the click on the LI items themselves captures branch contractions and expansion.

Joe Chung
Thanks, your comment made me realize it was the way I building the treeview (via JSON and adding branches)that was causing the issue. I was able to resolve my issue by assigning the click event right after I had added the dynamically generated branches.
WorkingWeb
A: 
Alexander