- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在寻找一种在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 modal, should fire when it CLOSES by clicking outside the modal (easy-close)
observeEvent(test, {
myText$input = input$myString
print("observed")
}, ignoreInit = T)
output$myOutput = renderText(myText$input)
}
shinyApp(ui = ui, server = server)
最佳答案
我想为不要求使用easyClose = TRUE的任何人提供一个更简单的答案,就像OP那样-在这种情况下,这比SBista注释中的链接要容易得多。
这只是用您自己的操作按钮替换了模态的默认“关闭”按钮,这使您可以在关闭模态时执行一些其他操作。这是通过footer =
参数设置的。
在此示例中,模态包含复选框,直到关闭模态后复选框才生效。
library(shiny)
shinyApp(
ui <- fluidPage(
fluidRow(
## Button to display modal:
actionButton(inputId = "display_modal",label = "Display modal"),
## Print the choices that were made in the modal:
h1(textOutput("checked_letters"))
)
),
server <- function(input, output) {
## These values allow the actions made in the modal to be delayed until the
# modal is closed
values = reactiveValues(to_print = "", ## This is the text that will be displayed
modal_closed=F) ## This prevents the values$to_print output from
# updating until the modal is closed
## Open the modal when button clicked
observeEvent(input$display_modal,{
values$modal_closed <- F
showModal(modalDialog(
checkboxGroupInput("checkboxes",label = "Select letters",
choices = LETTERS[1:7]),
## This footer replaces the default "Dismiss" button,
# which is 'footer = modalButton("Dismiss")'
footer = actionButton("dismiss_modal",label = "Dismiss")
))
})
## This event is triggered by the actionButton inside the modalDialog
# It closes the modal, and by setting values$modal_closed <- T, it
# triggers values$to_print to update.
observeEvent(input$dismiss_modal,{
values$modal_closed <- T
removeModal()
})
## values$to_print is only updated once the modal is closed.
observe({
if(values$modal_closed){
values$to_print <- paste(input$checkboxes)
}
})
## Forward the values$to_print to the UI
output$checked_letters = renderText({values$to_print})
}
)
关于r - 观察Shiny中的模式(轻松)关闭,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45245681/
我尝试将resteasy与自定义对象一起使用,当我创建jar文件时,它与intellij IDE一起工作正常,但失败并出现以下异常 org.jboss.resteasy.core.NoMessageB
我正在寻找一种在easy-close选项为TRUE时基于Shiny模态关闭触发事件的方法(因此,在模态外部单击将其关闭)。由于没有链接到模式的ID,因此我似乎无法捕获此事件。我尝试在“观察”事件中包装
假设我有一些定义如下的类: class Security { Boolean AuthenticateUser(String username, String password); B
正如标题所说,Coq 可以用作模型检查器吗?我可以将模型检查与 Coq 证明混合使用吗?这是常态吗?谷歌谈论“微积分”,有没有人有这方面的经验或类似的经验?是否建议以这种方式使用 Coq,或者我应该寻
是否有一种方法(设置或快捷方式)可以显示输出超过 500 行的查询的总行数 - 即,无需修改首选项中的“结果集页面大小”值?我本质上是在寻找 select count(*) from () t 的输出
我想这样做: System.out.println("안녕하세요!"); 但是当我尝试在 Eclipse 中进行编译时,出现“某些字符无法使用 MacRoman 字符编码进行编码”弹出式错误消息。我正
如果我有一个用这样的字符串初始化的框架 setter CTFramesetterRef framesetter = CTFramesetterCreateWithAttributedString(at
所以这里没有什么新内容,我只是想得到一些澄清,但似乎在其他帖子中找不到任何澄清。 我正在安静地创建一个新资源,例如: /books (POST) 有一个 body : { title: 'The
我有很多预处理器宏定义,如下所示: #define FOO 1 #define BAR 2 #define BAZ 3 在实际应用中,每个定义对应一个解释器虚拟机中的一条指令。宏的编号也不是连续的,以
使用 SpriteKit 开发 iOS 游戏。我的背景由 map block 组成(本质上是无限 map ,程序生成)。 我们的系统旨在管理 map 的“ block ”,我们只加载玩家附近的 blo
我需要在 Ruby 中拆分一个具有以下格式的字符串: [{a:1,b:2,c:3,d:4},{a:5,b:6,c:7,d:8},{a:9,b:10,c:11,d:12},{a:13,b:14,c:1
Linq 有一个名为 Take() 的便捷运算符方法,可以返回任何实现 IEnumerable 的元素中给定数量的元素。 jQuery 中是否有类似的东西可以处理数组? 或者,换个方式问:如何在 Ja
每当我使用以下代码在文档中插入图像时, var cursor = DocumentApp.getActiveDocument().getCursor(); var image = cursor
今天看到这样一段代码: if ( not defined($reply_address) or not defined($from_name) or not defined(
这个问题不太可能帮助任何 future 的访问者;它只与一个小的地理区域、一个特定的时间点或一个非常狭窄的情况有关,这些情况并不普遍适用于互联网的全局受众。为了帮助使这个问题更广泛地适用,visit
刚刚了解 mercurial 的 --style和 --template可用于 hg log 的选项和 hg tip我发现它们非常有帮助,但我不知道把我的“样式文件”放在哪里 我有一个“样式文件”,它
是否有一些应用程序可以自动 bundle (并缩小)包含 require('file.js') 调用的 JS 项目?这样它们就会合并并生成一个文件。 具体来说,我正在谈论when.js ,一个带有大量
如何(轻松)获取 Sublime Text 3 中的当前文件路径 我不经常使用 ST 控制台(我只使用它一次来安装包管理器),但我认为这可能是一个好方法: 像某种pwd命令一样获取当前文件路径。 但这
嗨,我正在使用resteasy api,我需要使用Map作为QueryParam。我可以使用列表作为 QueryParam,但是当我尝试传递 Map 时,我收到下面提到的错误。 这是我的服务代码 @G
假设我有一个 C++ 代码(请参阅下面的简单示例)。我想让期刊审稿人轻松安装/运行 所以我认为最简单的方法是将其变形为简化的类 R 包的 tar.gz 文件,以便裁判可以安装它通过简单地调用 inst
我是一名优秀的程序员,十分优秀!