Christian Ziebarth
Christian Ziebarth

Reputation: 753

jstree killing live links

Am implementing the jsTree plugin (http://www.jstree.com) on a project and it is generally working but it seems to prevent any links within the list that it is applied to from working. I have a Codepen example here:

http://codepen.io/WebDevCA/full/yinhk

If you go to Team A's Projects > Iteration 1 > Story A

then Story A should act as a link to Twitter (you can roll over the link to see that it points there). But jsTree keeps the link from working. Remove jsTree and the link works. Is there any way to convince jsTree to let it work?

Upvotes: 2

Views: 273

Answers (2)

Christian Ziebarth
Christian Ziebarth

Reputation: 753

I have since implemented one possible solution using the following code:

$(document).on('click', '#selector A', function () {
  var goHere = $(this).attr("href");
  window.location.href = goHere;
});

The Codepen linked to above has been updated to show it working. http://codepen.io/WebDevCA/full/yinhk

Upvotes: 1

John - Not A Number
John - Not A Number

Reputation: 659

The problem is jstree uses the mouse click for a select event. If you want to do something else when the node is selected, then you'll need to bind to the select event:

    $("#tree").jstree(
      // options...
    ).bind("select_node.jstree", function (evt, data) {
      // your code here...
      // id of selected node will be: data.inst.get_selected()[0].id
    });

Upvotes: 2

Related Questions