[jsTree:3400] How to give an url link to anchor tag

978 views
Skip to first unread message

Prem Kumar

unread,
May 10, 2010, 9:43:01 AM5/10/10
to jsTree
Hi All,

I am newbie, please help me, anchor tag is not clickable[not taking me
to the URL]

please find below the code

<ul>
<li class="open">
<a href="subgroup_9/" class="">Sub Group3 . 1</a>
<ul>
<li class="leaf"><a href="test_10/
index.php" class="clicked">Test10</a></li>
<li class="leaf"><a href="test_11/
index.php" class="">Test11</a></li>
<li class="leaf"><a href="test_12/
index.php" class="">Test12</a></li>
<li class="last leaf"><a href="test_13/
index.php" class="">Test13</a></li>
</ul>
</li>
<li class="last closed">
<a href="/subgroup_10/">Sub Group3 . 2</a><br/>
<ul>
<li class="leaf"><a href="test_14/
index.php">Test14</a></li>
<li class="last leaf"><a href="test_15/
index.php">Test15</a></li>
</ul>
</li>
</ul>

Even if anchor tag has an url like "test_10/index.php", onclicking on
that anchor text it is not going to the specified URL, please tell me
how can I make this to work

--
You received this message because you are subscribed to the Google Groups "jsTree" group.
To post to this group, send email to jst...@googlegroups.com.
To unsubscribe from this group, send email to jstree+un...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/jstree?hl=en.

Terry Clancy

unread,
Jun 7, 2015, 5:04:55 AM6/7/15
to jst...@googlegroups.com, saip...@gmail.com
I have the same problem - any ideas since 2010 ?

Terry Clancy
ClanceZ

Ivan Bozhanov

unread,
Jun 7, 2015, 5:25:59 AM6/7/15
to jst...@googlegroups.com, terry...@live.com, saip...@gmail.com
This has been solved countless times both here and on stackoverflow. I know the groups search feature is horrible so I apologize you could not find the solution easily - I am working on replacing the groups page with some other mailing list but so far no luck.
As for the question - jstree will capture all clicks, but will fire off events which you can use to react to user clicks, so in your case, provided you filled in the href attributes (more on that below) all you need to do is:
$('#your-tree').on('select_node.jstree', function (e, data) {
    window.location = data.node.a_attr.href; // of course you do not need to change window.location - do whatever you need with the value
});
As for populating the href attribute - if you are using HTML - just specify it on the links: <a href="..."
If you are using JSON, you need to add this for each node: { "a_attr" : { "href" : "http://..." }, ...

Best regards,
Ivan
Reply all
Reply to author
Forward
0 new messages