当easy-close选项为TRUE时,我正在寻找一种基于关闭Shiny模式触发事件的方法(因此在模态外点击会关闭它).由于没有ID链接到模态,我似乎无法捕捉到这个事件.我尝试在"观察"事件中包装模态,但这只会触发开启但不会关闭模态.
任何想法......谢谢
示例:如果此模态通过单击其外部关闭,我想触发事件,因此不是关闭按钮.以下代码仅在打开时触发...
library(shiny)
ui <- fluidPage(
fluidRow(
actionButton(inputId = "enterText", label = "Enter name", align = "left"),
h1(textOutput("myOutput"))
)
)
server <- function(input, output, session) {
myText <- reactiveValues(input = "...")
myModal = modalDialog(h3("Enter a string, then click outside this modal to close and display the text"),
textInput(inputId = "myString", label = "Enter a string: "),
title = "Input", easyClose = TRUE, footer = modalButton("Dismiss"))
test = observe(myModal)
#Open the modal when button clicked
observeEvent(input$enterText,{
showModal(myModal)
})
#Observe the …Run Code Online (Sandbox Code Playgroud) 我已经使用 trap 函数有一段时间了,但遇到了一个我不明白的问题。
这是一个代表:
err_report() {
echo -e "ERROR LINE $1"
exit 1;
}
trap 'err_report ${LINENO}' ERR
existing=$(echo test | grep -oP "x")
Run Code Online (Sandbox Code Playgroud)
这将引发错误,因为 grep 的结果为空。当我在没有陷阱的情况下运行代码时,一切正常。我尝试设置set +u但没有帮助..
我在这里做错了什么?
谢谢