r - Actionbutton在R闪亮中第一次不起作用
问题描述
我已将此代码用于一个简单的应用程序,以从用户那里接收系统和站点名称。我第二次按“提交”按钮时遇到问题。例如,如果用户在没有选择系统/选择站点的情况下直接按“提交”,则会弹出“请确保系统不为空”。这是第一次按“提交”,但是当用户选择了系统并且站点然后第二次按“提交”时,它不起作用。有谁知道如何解决它?
这是我的代码。
library(shiny)
library(shinyWidgets)
library(shinycssloaders)
library(shinythemes)
library(shinyTime)
library('tools')
# Define UI for application that draws a histogram
ui <- fluidPage(
theme = shinytheme("cyborg"),
# Application title
titlePanel("test"),
sidebarLayout(
sidebarPanel(
selectizeInput('system', '* Select System:', width = '100%',
choices = c("a","b","c"), multiple = FALSE,
options = list(
placeholder = 'Please Select Site',
onInitialize = I('function() { this.setValue(""); }')
)),
selectizeInput('site', '* Select Site:', width = '100%',
choices = c("A","B","C"), multiple = FALSE,
options = list(
placeholder = 'Please Select Site',
onInitialize = I('function() { this.setValue(""); }')
)),
hr(),
actionBttn(inputId = "submit", label= "Submit for Processing")
),
mainPanel(
h4("Test review")
)
)
)
server <- function(input, output, session) {
# observe submit
observeEvent(input$submit, {
print("test input submit button 2")
if (input$system=="") {
showModal(modalDialog(
title = "Error",
"Please make sure system is not empty."
))
}else if (input$site==""){
print("test1")
showModal(modalDialog(
title = "Error",
"Please make sure site is not empty."
))
}else {
showModal(modalDialog(
title = "Good",
"success"
))
}
}, once = TRUE)
}
# Run the application
shinyApp(ui = ui, server = server)
解决方案
推荐阅读
- php - 在多个子文件夹中搜索最新图像,抓取它重命名并删除子文件夹和图像
- c++ - C++ 重载 wchar_t 赋值运算符
- c# - 如何在使用 Visual Studio 启动项目后修复项目
- html - URI 中的几个波浪号 (~) 是什么意思?
- php - 对同一个 URL 执行多个并行 cURL?
- cxf - 在 Service Mix 上更改 cxf 的版本
- android - 改造 onFailure 中的 getMessage 返回 null
- spring - 使用构造函数表达式和 JPQL 使用 DTO 投影获取列表
- eclipse - Eclipse 插件无法重新安装
- php - 浏览器上的 JSON 缓存标头不起作用