关闭R闪亮

时间:2018-02-01 17:54:31

标签: jquery r shiny modal-dialog showmodaldialog

我的应用中有一个与下方虚拟应用中的情况相匹配的情景。 我真正的应用程序所做的是在checkboxes中显示dropdownmenu来自dropdownButton的数据框中每个可用列,供用户从中选择要运行的模型。 我要构建的是modalDialogtriggered hovermodal,显示用户悬停的列中的数据图。 目前,我完成了所有工作,但还有一个问题:

如果用户使用histogram关闭dialog window,则下拉按钮的plot也会消失。如何只保留dialog closecheckboxes,同时保持所有library(shiny) library(shinyjs) shinyApp( ui = fluidPage( useShinyjs(), dropdownButton(label = "CLICK", h5("This is the dropdownbutton window" ), checkboxInput("Checker", "Hover for modal dialog"), icon = icon("tasks"), inputId = "MYDDMbut", circle = T, status = "info", tooltip = tooltipOptions(title = "Click to open window"), width = "400px") ), server = function(input, output, session) { output$distPlot <- renderPlot({ hist(mtcars$disp) }) onevent('mouseover','Checker',{ delay(1000, showModal(div(id="ModalDiv", modalDialog( inputId = "distPlot", title = HTML('<span style="color:#339fff; font-size: 20px; font-weight:bold; font-family:sans-serif ">Current data column<span> <button type = "button" class="close" data-dismiss="modal" "> <span style="color:#339fff; ">x <span> </button> '), br(), plotOutput("distPlot"), br(), easyClose = TRUE, footer = NULL )))) print("2")}, T) } ) 打开?

这是一个带有问题的虚拟应用程序:

        SUBROUTINE hello (Characters)
CHARACTER*(16)  Characters(5)
Characters=(/"ABCD","BCDF","CVFG","D HG","J67F"/)
return
END

1 个答案:

答案 0 :(得分:3)

我移除了模态&amp;上的近十字。在fotter上添加一个OK按钮并在其上放置一个observeEvent

library(shiny)
library(shinyjs)
library(shinyWidgets)

shinyApp(


    ui = fluidPage(
        useShinyjs(),

        dropdownButton(label = "CLICK",
                       h5("This is the dropdownbutton window" ),
                       checkboxInput("Checker", "Hover for modal dialog"),
                       icon = icon("tasks"),
                       inputId = "MYDDMbut",
                       circle = T, 
                       status = "info", 
                       tooltip = tooltipOptions(title = "Click to open window"), width = "400px")
    ),

    server =  function(input, output, session) {
        output$distPlot <- renderPlot({
            hist(mtcars$disp)
        })


        onevent('mouseover','Checker',{
                 showModal(div(id="ModalDiv", modalDialog(
                      inputId = "distPlot",
                      title = HTML('<span style="color:#339fff; font-size: 20px; font-weight:bold; font-family:sans-serif ">Current data column<span>'),
                      br(),
                      plotOutput("distPlot"),
                      footer = tagList(actionButton("close", "OK")) )))
            print("2")}, T)

        observeEvent(input$close, {
            removeModal()
            toggleDropdownButton(inputId = "MYDDMbut")
        })
    }
        )