From baa90719d303ad70784fbf0224cdb87720c519a7 Mon Sep 17 00:00:00 2001 From: Ro3A Date: Sat, 26 Nov 2016 17:20:05 -0500 Subject: [PATCH] Custom data attributes on tree item Adds data-* attributes for key value pairs provided in "dataAttributes" property for each node --- src/js/bootstrap-treeview.js | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/js/bootstrap-treeview.js b/src/js/bootstrap-treeview.js index 7a82a2eeb..fb92f887c 100644 --- a/src/js/bootstrap-treeview.js +++ b/src/js/bootstrap-treeview.js @@ -519,6 +519,13 @@ .addClass(node.searchResult ? 'search-result' : '') .attr('data-nodeid', node.nodeId) .attr('style', _this.buildStyleOverride(node)); + + //Add data attributes + if (node.dataAttributes) { + $.each(node.dataAttributes, function addDataAttibutes(key, value) { + treeItem.attr("data-" + key, value); + }); + } // Add indent/spacer to mimic tree structure for (var i = 0; i < (level - 1); i++) {