Skip to content
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
9 changes: 8 additions & 1 deletion dash/_callback_context.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,9 @@ def triggered_prop_ids(self):
@has_context
def triggered_id(self):
"""
Returns the component id (str or dict) of the Input component that triggered the callback.
Returns the component id of the Input that triggered the callback. The id is a string
for a regular component and a dictionary for a pattern-matching component.
Returns None when no Input triggered the callback, such as on an initial call.

Note - use `triggered_prop_ids` if you need both the component id and the prop that triggered the callback or if
multiple Inputs triggered the callback.
Expand All @@ -130,6 +132,11 @@ def triggered_id(self):
`if "btn-1" == ctx.triggered_id:
do_something()`

Example - read a key from a pattern-matching id:
`triggered_id = ctx.triggered_id
if isinstance(triggered_id, dict):
index = triggered_id.get("index")`

"""
component_id = None
if self.triggered:
Expand Down