# NOT RUN {
if (interactive()) {
library(shiny)
shinyApp(
ui = fluidPage(
useShinyjs(), # Set up shinyjs
p(id = "date", "Click me to see the date"),
p(id = "coords", "Click me to see the mouse coordinates"),
p(id = "disappear", "Move your mouse here to make the text below disappear"),
p(id = "text", "Hello")
),
server = function(input, output) {
onclick("date", alert(date()))
onclick("coords", function(event) { alert(event) })
onevent("mouseenter", "disappear", hide("text"))
onevent("mouseleave", "disappear", show("text"))
}
)
}
# }
# NOT RUN {
# The shinyjs function call in the above app can be replaced by
# any of the following examples to produce similar Shiny apps
onclick("disappear", toggle("text"))
onclick(expr = text("date", date()), id = "date")
# }
Run the code above in your browser using DataLab