Reputation: 191
This is probably so simple to someone but cant figure it out. I have this code that shows a node in an alert box. How do I add this to the nodes href value ie www.example.com/connector/(nodes number). Also there seems to be a prevent default somehere that stops click events. How do I remove that?. Is there a simple way in jquery.
The code I have is below.
$("#demo")
.bind("select_node.jstree", function (event, data) {
var selectedObj = data.rslt.obj;
alert(selectedObj.attr("id") + selectedObj.attr("data"));
This produces the alert with node number.
From the source code I need to add to the href value below.
<li id="node_80" rel="folder" class="jstree-closed"><ins class="jstree-icon"> </ins><a href="#" class="jstree-clicked"><ins class="jstree-icon"> </ins>TEST</a></li>
Upvotes: 1
Views: 212
Reputation: 191
With thanks to Manatok.
I managed to get this working, by using jquery replace. adding
.replace("node_","") ie selectedObjx.attr("id").replace("node_",""));
I have added this in case anyone has similar problems. Many thanks for everyones help. – user1074541 Feb 27 at 22:03
Upvotes: 0
Reputation: 5706
Maybe something like this:
$("#demo")
.bind("select_node.jstree", function (event, data) {
var selectedObj = data.rslt.obj;
$('.jstree-clicked').attr("href","www.example.com/connector/"+selectedObj.attr("id"));
...
Upvotes: 4