【问题标题】:R shinyBS modal pop up stopped working and can't make it to work with Shiny ServerR shinyBS 模态弹出窗口停止工作,无法与 Shiny Server 一起使用
【发布时间】:2020-05-15 08:17:51
【问题描述】:

我在下面有一个简单的示例,说明用户进入网站时的闪亮BS 模态弹出概念。这工作正常,现在突然停止工作。我有闪亮的服务器专业版。不仅模式不显示,而且数据表也没有呈现。就好像服务器端根本没有运行。我得到一个空白页。

library(shiny)
library(shinyBS)
library(DT)

ui <- fluidPage(
  fluidRow(
    bsModal(
      id = 'startupModal',
      title = h4('IMPORTANT NOTICE. MUST READ AND ACKNOWLEDGE!'),
      trigger = '', size = 'large',
      p('The system you are entering is proprietary ... Do not mess with us!')
      )
    ),
  fluidRow(
    mainPanel(
      DT::dataTableOutput('myData'),
      width = 12
      )
    )
  )

server <- function(input, output, session) {
  toggleModal(session, "startupModal", toggle = "open")
  output$myData <- DT::renderDataTable({
    mtcars %>%
      DT::datatable(
        escape = FALSE, class = 'compact', rownames = '', filter = 'none'
        )
    })
  }

shinyApp(ui, server)

如果我如下注释掉模态 UI,页面和数据表呈现正常。

library(shiny)
library(shinyBS)
library(DT)

ui <- fluidPage(
#   fluidRow(
#     bsModal(
#       id = 'startupModal',
#       title = h4('IMPORTANT NOTICE. MUST READ AND ACKNOWLEDGE!'),
#       trigger = '', size = 'large',
#       p('The system you are entering is proprietary ... Do not mess with us!')
#       )
#     ),
  fluidRow(
    mainPanel(
      DT::dataTableOutput('myData'),
      width = 12
      )
    )
  )

server <- function(input, output, session) {
  toggleModal(session, "startupModal", toggle = "open")
  output$myData <- DT::renderDataTable({
    mtcars %>%
      DT::datatable(
        escape = FALSE, class = 'compact', rownames = '', filter = 'none'
        )
    })
  }

shinyApp(ui, server)

这里是关于包和 R 运行的更多信息:

R version 3.4.1 (2017-06-30) -- "Single Candle"
Copyright (C) 2017 The R Foundation for Statistical Computing
Platform: x86_64-pc-linux-gnu (64-bit)

R is free software and comes with ABSOLUTELY NO WARRANTY.
You are welcome to redistribute it under certain conditions.
Type 'license()' or 'licence()' for distribution details.

  Natural language support but running in an English locale

R is a collaborative project with many contributors.
Type 'contributors()' for more information and
'citation()' on how to cite R or R packages in publications.

Type 'demo()' for some demos, 'help()' for on-line help, or
'help.start()' for an HTML browser interface to help.
Type 'q()' to quit R.

> packageVersion('shiny')
[1] ‘1.4.0’
> packageVersion('shinyBS')
[1] ‘0.61’
> packageVersion('DT')
[1] ‘0.5’

shiny-server --version
Shiny Server Pro v1.5.12.1023
Node.js v10.15.3

我在 Chrome(包括启用弹出窗口的设置)和 Microsoft Edge 上都试过这个。它们都不起作用。

【问题讨论】:

  • 好吧,看起来这是与最新版本闪亮的兼容性问题。 github.com/ebailey78/shinyBS/issues/112。有谁知道如何解决?是的,我可以降级闪亮的软件包版本,但不想养成这个习惯。

标签: r shiny shinybs


【解决方案1】:

这不是修复,而是一种解决方法。

通过测试发现问题出在bsModal的触发参数上。缺少值(也不接受空格/空白值)会导致问题。

如果您可以添加某种标识符字符串,例如表格标题,则模式窗口会再次弹出,即使使用shiny 1.4.0。我添加了'Project Title' 字符串 到mainPanel以及modal中的trigger参数。

下面是一个工作示例(我的包版本在底部)。

希望这对您的情况有所帮助。

library(shiny)
library(shinyBS)
library(DT)

ui <- fluidPage(
       fluidRow(
         bsModal(
           id = 'startupModal',
           title = h4('IMPORTANT NOTICE. MUST READ AND ACKNOWLEDGE!'),
           trigger = 'Project Title', size = 'large',
           p('The system you are entering is proprietary Do not mess with us')
           )
         ),

    fluidRow(
        mainPanel(h3("Project Title"),
            DT::dataTableOutput('myData'),
            width = 12
        )
    )
)

server <- function(input, output, session) {
    toggleModal(session, "startupModal", toggle = "open")
    output$myData <- DT::renderDataTable({
        mtcars %>%
            DT::datatable(
                escape = FALSE, class = 'compact', rownames = '', filter = 'none'
            )
    })
}

shinyApp(ui, server)

R version 3.6.0 (2019-04-26)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.6 LTS

Matrix products: default
BLAS:   /usr/lib/atlas-base/atlas/libblas.so.3.0
LAPACK: /usr/lib/atlas-base/atlas/liblapack.so.3.0

Random number generation:
 RNG:     Mersenne-Twister 
 Normal:  Inversion 
 Sample:  Rounding 

locale:
 [1] LC_CTYPE=C.UTF-8       LC_NUMERIC=C           LC_TIME=C.UTF-8       
 [4] LC_COLLATE=C.UTF-8     LC_MONETARY=C.UTF-8    LC_MESSAGES=C.UTF-8   
 [7] LC_PAPER=C.UTF-8       LC_NAME=C              LC_ADDRESS=C          
[10] LC_TELEPHONE=C         LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C   

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] DT_0.9       shinyBS_0.61 shiny_1.4.0 

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.2        rstudioapi_0.10   magrittr_1.5      tidyselect_0.2.5 
 [5] munsell_0.5.0     xtable_1.8-4      colorspace_1.4-1  R6_2.4.0         
 [9] rlang_0.4.0       fastmap_1.0.1     dplyr_0.8.3       tools_3.6.0      
[13] grid_3.6.0        gtable_0.3.0      sourcetools_0.1.7 crosstalk_1.0.0  
[17] htmltools_0.4.0   yaml_2.2.0        lazyeval_0.2.2    assertthat_0.2.1 
[21] digest_0.6.21     tibble_2.1.3      crayon_1.3.4      purrr_0.3.2      
[25] ggplot2_3.2.1     later_1.0.0       htmlwidgets_1.5.1 promises_1.1.0   
[29] glue_1.3.1        mime_0.7          compiler_3.6.0    pillar_1.4.2     
[33] scales_1.0.0      jsonlite_1.6      httpuv_1.5.2      pkgconfig_2.0.3

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2011-05-20
    • 2019-05-26
    • 1970-01-01
    • 1970-01-01
    • 2023-01-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多