Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added search function to tree.

  • Loading branch information...
commit b19b78bd9ec10a7b0cb4286a64d015bcb5bc599a 1 parent 397115e
Nameless authored
Showing with 18 additions and 2 deletions.
  1. +4 −2 canvas/static/loadtree.js
  2. +14 −0 templates/canvas/playground.html
6 canvas/static/loadtree.js
View
@@ -15,9 +15,11 @@ function loadTree(treedata, checked_nodes) {
return [feeling+"_check", 'feeling', feeling];
}
},
- plugins: ['themes', 'json_data', 'ui', 'checkbox']
+ 'search': {
+ 'show_only_matches': true
+ },
+ plugins: ['themes', 'json_data', 'ui', 'checkbox', 'search']
}).bind("loaded.jstree", function (event, data) {
- console.log(checked_nodes.length);
for(node in checked_nodes)
{
console.log(checked_nodes[node]);
14 templates/canvas/playground.html
View
@@ -15,6 +15,7 @@
{% block content %}
<div id="toolbox">
+ <input type="text" id="treeSearch" value"Search for feelings" /> <button id="searchButton">Search</button>
<form action="">
{% csrf_token %}
<div id="feelingtree"></div>
@@ -40,5 +41,18 @@
alert(this.getBBox().width);
} );
{% endfor %}
+
+ var timer;
+
+ $("#treeSearch").keyup(function() {
+ console.log("Clearing timeout...");
+ clearTimeout(timer); // Clear the timer so we don't end up with dupes.
+ var text = $(this).val();
+ timer = setTimeout(function() {
+ console.log("Executing...");
+ $("#feelingtree").jstree("search", text);
+ }, 500);
+ console.log("New timeout set.");
+ });
</script>
{% endblock %}
Please sign in to comment.
Something went wrong with that request. Please try again.