如何使鼠标悬停时出现侧边栏而不是在“闪亮"中单击? [英] How to make appear sidebar on hover instead of click in Shiny?
本文介绍了如何使鼠标悬停时出现侧边栏而不是在“闪亮"中单击?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在开发一个闪亮的应用程序,并且UI部分使用了Shinydashboard程序包.我想在悬停时打开侧边栏,而不是单击按钮.我尝试了数据触发选项,但是它不起作用.有人可以帮我吗?
I am working on a shiny application and have used shinydashboard package for the UI part. I want to open the sidebar on hover instead of click on the button. I have tried data-trigger option but it is not working. Can anyone please help me in doing this?
闪亮的仪表板应用程序的最小示例
A minimal example for the shiny dashboard application
## app.R ##
library(shiny)
library(shinydashboard)
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody()
)
server <- function(input, output) { }
shinyApp(ui, server)
推荐答案
您可以使用JQuery做到这一点:
You can do it with 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)
这篇关于如何使鼠标悬停时出现侧边栏而不是在“闪亮"中单击?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文