Description Usage Arguments Event types See Also Examples
This function can be used to revert the action of
onclick
or onevent
.
1 | removeEvent(event, id, asis = FALSE)
|
event |
Either an event type (see below for a list of event types) or
an event ID (the return value from
|
id |
The ID of the element/Shiny tag. Must match the ID used in
|
asis |
If |
Any standard mouse or
keyboard events
that are supported by JQuery can be used. The standard list of events that can be used is:
click
, dblclick
, hover
, mousedown
, mouseenter
,
mouseleave
, mousemove
, mouseout
, mouseover
, mouseup
,
keydown
, keypress
, keyup
. You can also use any other non
standard events that your browser supports or with the use of plugins (for
example, there is a mousewheel
plugin that you can use to listen to mousewheel events).
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | if (interactive()) {
library(shiny)
shinyApp(
ui = fluidPage(
useShinyjs(), # Set up shinyjs
p(id = "myel", "Hover over me to see the date, the time, and a random integer"),
actionButton("remove_date", "Remove date hover event"),
actionButton("remove_all", "Remove all hover events")
),
server = function(input, output) {
onevent("hover", "myel", print(format(Sys.time(), "%H:%M:%S")))
onevent("hover", "myel", print(sample(100, 1)), add = TRUE)
date_event_id <- onevent("hover", "myel", print(as.character(Sys.Date())), add = TRUE)
observeEvent(input$remove_all, {
removeEvent("hover", "myel")
})
observeEvent(input$remove_date, {
removeEvent(date_event_id, "myel")
})
}
)
}
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.