Skip to content
This repository has been archived by the owner on Dec 13, 2018. It is now read-only.

Fix: Make sure that when an tree item text contains a link, the link is followed… #353

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions src/js/bootstrap-treeview.js
Original file line number Diff line number Diff line change
Expand Up @@ -315,8 +315,23 @@
};

Tree.prototype.clickHandler = function (event) {

if (!this.options.enableLinks) event.preventDefault();
if (!this.options.enableLinks) {
//walk to parents till we find our list item
var bFoundLink = false;
var currentTarget = event.target;

while (!bFoundLink //Found link
&& currentTarget //No target
&& !currentTarget.classList.contains('list-group-item') //tree item root
) {
bFoundLink = currentTarget.nodeName == "A";
currentTarget = currentTarget.parentElement;
}
if (bFoundLink) {
return; // Handle link
}
event.preventDefault(); //Normal collapse behavior
}

var target = $(event.target);
var node = this.findNode(target);
Expand Down