如何使鼠标悬停时出现侧边栏而不是单击“闪亮”?

时间:2019-12-19 11:41:39

标签: r shiny hover

我正在开发一个闪亮的应用程序,并且UI部分使用了Shinydashboard软件包。我想在悬停时打开侧边栏,而不是单击按钮。我尝试了数据触发选项,但是它不起作用。有人可以帮我吗?

闪亮的仪表板应用程序的最小示例

## app.R ##
library(shiny)
library(shinydashboard)

ui <- dashboardPage(
  dashboardHeader(),
  dashboardSidebar(),
  dashboardBody()
)

server <- function(input, output) { }

shinyApp(ui, server)

1 个答案:

答案 0 :(得分:1)

您可以使用JQuery做到这一点

## app.R ##
library(shiny)
library(shinydashboard)

ui <- dashboardPage(
  dashboardHeader(),
  dashboardSidebar(),
  dashboardBody(),
  tags$head(tags$script(HTML("$(function() { $('a.sidebar-toggle').mouseover(function(e) { $(this).click()})});")))
)

server <- function(input, output) { }

shinyApp(ui, server)