gpt4 book ai didi

r - Shiny 仪表板加 : Opening a closed boxPlus

转载 作者:行者123 更新时间:2023-12-04 04:21:15 26 4
gpt4 key购买 nike

最佳答案

我一直在寻找同一个问题的答案,我已经想出了如何使用 shinyjs 来解决这个问题。

library(shinydashboardPlus)
library(shinydashboard)
library(shinyjs)
library(shiny)

ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(
useShinyjs(),
boxPlus(
id = "openable-box-plus",
title = "Openable boxPlus",
closable = TRUE
),
actionButton(
inputId = "open-box-plus",
label = "Open boxPlus"
)
)
)

server <- function(input, output) {
observeEvent(
input$`open-box-plus`,
runjs('
document
.querySelector("#openable-box-plus")
.parentElement
.style.display = "block";
')
)
}

shinyApp(ui, server)

检查boxPlus 关闭前后的HTML 时,可以看到样式display: none;被添加到 <div>class="box" .

enter image description here

要选择具体boxPlus我添加了 id = "openable-box-plus" .自 id去了 child divdivdisplay风格,你必须选择父元素,并更改 display"block" :

document
.querySelector("#openable-box-plus")
.parentElement
.style.display = "block";

关于r - Shiny 仪表板加 : Opening a closed boxPlus,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59259599/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com