View source: R/callbacks-advanced.R
prevent_update | R Documentation |
When used inside Dash callbacks, if any of the arguments evaluate to TRUE
,
then the callback's outputs do not update.
prevent_update(...)
... |
Values to check |
if (interactive()) {
app <- dash_app()
app %>% set_layout(
button('Click here', id = 'btn'),
p('The number of times the button was clicked does not
update when the number is divisible by 5'),
div(id = 'body-div')
)
app %>% add_callback(
output(id='body-div', property='children'),
list(
input(id='btn', property='n_clicks')
),
function(n_clicks) {
prevent_update(is.null(n_clicks[[1]]), n_clicks[[1]] %% 5 == 0)
paste(n_clicks[[1]], "clicks")
}
)
app %>% run_app()
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.