我有一个闪亮的仪表板,在登录页面上只有一个文本框。用户输入显示相关数据的电子邮件ID。这个很好用。然而,我需要一个框/选项卡面板,问候用户到达页面,当用户开始在文本输入中输入文本(电子邮件ID)时消失。这可能吗?
output$introbox=renderUI(box(h3("Welcome to the page. Please enter your email id to proceed")),
conditionalPanel(condition=input.emailid=="")
该框在登录页面时显示,但在输入文本时不会消失。
感谢您的帮助。谢谢
奥斯卡的答案是正确的。但它实际上并不使用shinyjs,它手动包含了所有的JavaScript。您可以使用他的答案,但这里使用shinyjs重写了他的答案
library(shiny)
library(shinydashboard)
library(shinyjs)
ui <-dashboardPage(
dashboardHeader(),
dashboardSidebar(
),
dashboardBody(
useShinyjs(),
div(id = "greetbox-outer",
box( id ="greetbox",
width = 12,
height = "100%",
solidHeader = TRUE,
status = "info",
div(id="greeting", "Greeting here")
)
),
box( id ="box",
width = 12,
height = "100%",
solidHeader = TRUE,
status = "success",
textInput("txtbx","Enter text: ")
)
)
)
server <- shinyServer(function(input, output, session) {
observeEvent(input$txtbx,{
if (input$txtbx == "") return(NULL)
hide(id = "greetbox-outer", anim = TRUE)
print(input$txtbx)
})
})
shinyApp(ui = ui, server = server)