![](/img/trans.png)
[英]R shinyBS modal pop up stopped working and can't make it to work with Shiny Server
[英]shinyBS modal not working with Shiny Server PRO
我有以下示例應用程序,它提供了一個帶有數據表輸出的模式。
這在 RStudio 中工作,在任何瀏覽器中本地工作,在帶有 Shiny Server(免費版)的 EC2 Linux 實例上工作。 但是,不適用於 Shiny Server PRO。 關於限制的任何想法? 我試着調試了我知道的所有方式,並沒有發現問題。
library(shiny)
library(DT)
library(shinyBS)
library(dplyr)
mtcarsSummary <- mtcars %>%
group_by(am) %>%
summarise(numCars = n())
makeSummaryLinked <- function(df, linkName1, modalName1)
{
on_click_js1 = paste(
'Shiny.onInputChange('', linkName1, '', '%s'); $('',
modalName1, '').modal('show')', sep = ''
)
dfLinked <- df
tagList1 <- tags$a(
href = "#",
onclick = sprintf(on_click_js1, df$am),
df$am
)
tagList1 <- data.frame(V1 = tagList1$attribs$onclick, V2 = tagList1$children)
colnames(tagList1) <- c('V1', 'V2')
dfLinked$am_linked <- paste(
'<a href="#" onclick="', tagList1$V1, '">', tagList1$V2, '</a>', sep = ''
)
dfLinked <- select(
dfLinked, am_linked, everything()
)
return(dfLinked)
}
mtcarsLinked <- makeSummaryLinked(mtcarsSummary, 'myAm', paste0('#', 'amModal'))
ui <- fluidPage(
fluidRow(
mainPanel(
DT::dataTableOutput('myData'),
bsModal(
id = 'amModal',
title = 'What is this?',
trigger = '',
size = 'large',
mainPanel(
DT::dataTableOutput('amData'),
width = 12
)
),
width = 12
)
)
)
server <- function(input, output, session) {
amData <- reactive({
mtcars %>% filter(am == input$myAm)
})
output$myData <- DT::renderDataTable({
mtcarsLinked %>%
DT::datatable(
escape = FALSE, class = 'compact', rownames = '', filter = 'none',
options = list(dom = 'Bfrtrip')
)
})
output$amData <- DT::renderDataTable({
amData() %>%
DT::datatable(
escape = FALSE, class = 'compact', rownames = '', filter = 'none'
)
})
}
shinyApp(ui, server)
其余閃亮的東西工作正常。 R 工作正常。 所有軟件包都已正確安裝。
version
_
platform x86_64-pc-linux-gnu
arch x86_64
os linux-gnu
system x86_64, linux-gnu
status
major 3
minor 4.1
year 2017
month 06
day 30
svn rev 72865
language R
version.string R version 3.4.1 (2017-06-30)
nickname Single Candle
包版本如下:
packageVersion('shiny')
[1] ‘1.2.0’
packageVersion('DT')
[1] ‘0.5’
packageVersion('shinyBS')
[1] ‘0.61’
packageVersion('dplyr')
[1] ‘0.7.8’
我敢打賭,這是 Shiny Server 使用的<base>
標簽,這與#
等相對 href 混淆了。 如果您單擊該鏈接,它可能會將您導航到/_w_ad877768/#
類的地方。 您可以通過使用href="javascript:void(0)"
而不是href="#"
或在錨點的單擊處理程序中添加event.preventDefault()
來阻止導航。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.