forked from radovankavicky/dash-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstate.py
More file actions
50 lines (41 loc) · 1.81 KB
/
Copy pathstate.py
File metadata and controls
50 lines (41 loc) · 1.81 KB
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
from textwrap import dedent as s
import dash_core_components as dcc
import dash_html_components as html
from components import Example, Syntax
import tools
examples = {
'basic-input': tools.load_example('tutorial/examples/basic-input.py'),
'basic-state': tools.load_example('tutorial/examples/basic-state.py')
}
layout = html.Div([
html.H1('Dash State'),
dcc.Markdown(s('''
In the previous chapter on
[basic dash callbacks](/getting-started-part-2),
our callbacks looked something like:
''')),
Syntax(examples['basic-input'][0]),
Example(examples['basic-input'][1]),
dcc.Markdown(s('''
In this example, the callback function is fired whenever any of the
attributes described by the `dash.dependencies.Input` change.
Try it for yourself by entering data in the inputs above.
`dash.dependencies.State` allows you to pass along extra values without
firing the callbacks. Here's the same example as above but with the
`dcc.Input` as `dash.dependencies.State` and a button as
`dash.dependencies.Input`.
''')),
Syntax(examples['basic-state'][0]),
Example(examples['basic-state'][1]),
dcc.Markdown(s('''
In this example, changing text in the `dcc.Input` boxes won't fire
the callback but clicking on the button will. The current values of
the `dcc.Input` values are still passed into the callback even though
they don't trigger the callback function itself.
Note that we're triggering the callback by listening to the
`n_clicks` property of the `html.Button` component. `n_clicks` is a
property that gets incremented every time the component has been
clicked on. It is available in every component in the
`dash_html_components` library.
'''))
])