Hi Sullan,
your "dummy alert" gets fired when the document is loaded, which is
the same time you START loading your tree and you bind the click
event. However, neither is the tree loaded immediatly, nor does the
script wait until it is loaded, so you actually bind before the tree
is loaded, thus binding to non-existing elements.
You have three options here to solve this:
- bind the jstree event of select_node and access the node properties
to find your href
$('#demo1').bind('select_node.jstree', yourfunction)
- bind "loaded.jstree" event which is triggered after the tree is
fully loaded and bind your click event in there.
- use .live() to bind your event, which binds to all existing and
future elements that match the selector (see jQuery docs for details).
$('.treeLink').bind('click', yourfunction);