blob: 51962f6bbefa273c6de7c58e2369007d1e552edf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
---
title: Save the state in javascript tree
layout: page
js: examples/save_state.js
css: example.css
---
<p id="nav">
<a href="../03_drag_and_drop/">« Example 3</a>
<a href="../05_load_on_demand/" class="next">Example 5 »</a>
</p>
<h1>Example 4 - Save the state</h1>
<div id="tree1" data-url="/example_data/"></div>
<p>
If you set the option <strong>saveState</strong> to true, then jqtree remembers the tree state after a page reload.
</p>
<ul>
<li>
JqTree save the state into localStorage.
If the browser does not support localStorage, then jqTree saves the state in a cookie.
</li>
<li>
You must include the <a href="https://github.com/carhartl/jquery-cookie">jquery-cookie</a> plugin for cookie support.
</li>
</ul>
<h3>html</h3>
{% highlight html %}
<div id="tree1" data-url="/example_data/"></div>
{% endhighlight %}
<h3>javascript</h3>
{% highlight js %}
$('#tree1').tree({
saveState: true
});
{% endhighlight %}
<p>
Giving the <strong>saveState</strong> a string value sets the storage key. The default key is 'tree'.
</p>
{% highlight js %}
$('#tree1').tree({
saveState: 'my-tree'
});
{% endhighlight %}
|