2016-05-06 110 views
0

我使用庫shinythemes非常廣泛地在我構建的應用程序。我試圖利用shinyBS包中的bsModal,並注意到'淡入'div永遠不會離開我,因爲沒有任何可點擊的事情讓我有一個不可用的Web應用程序。閃亮 - bsModal全變成灰色與shinythemes

shinyBS::bsModal的例子都很好(他們是sans-shinythemes)。如何在使用模態的同時繼續使用主題?

示例應用程序:

library(shiny) 
library(shinyBS) 
library(shinythemes) 

app = shinyApp(
    ui = 
    navbarPage(title=NULL, 
     id="navbar", 
     theme = shinytheme("journal"), 
     tabPanel("test", 
     column(1), 
     column(3, 
      sliderInput("bins", 
      "Number of bins:", 
      min = 1, 
      max = 50, 
      value = 30), 
      actionButton("tabBut", "View Table") 
     ), 
     column(7, 
      plotOutput("distPlot"), 
      bsModal("modalExample", "Data Table", "tabBut", size = "large", 
      dataTableOutput("distTable")) 
     ) 
    ) 
    ), 
    server = 
    function(input, output, session) { 

     output$distPlot <- renderPlot({ 

     x <- faithful[, 2] 
     bins <- seq(min(x), max(x), length.out = input$bins + 1) 

     # draw the histogram with the specified number of bins 
     hist(x, breaks = bins, col = 'darkgray', border = 'white') 

     }) 

     output$distTable <- renderDataTable({ 

     x <- faithful[, 2] 
     bins <- seq(min(x), max(x), length.out = input$bins + 1) 

     # draw the histogram with the specified number of bins 
     tab <- hist(x, breaks = bins, plot = FALSE) 
     tab$breaks <- sapply(seq(length(tab$breaks) - 1), function(i) { 
      paste0(signif(tab$breaks[i], 3), "-", signif(tab$breaks[i+1], 3)) 
     }) 
     tab <- as.data.frame(do.call(cbind, tab)) 
     colnames(tab) <- c("Bins", "Counts", "Density") 
     return(tab[, 1:3]) 

     }, options = list(pageLength=10)) 

    } 
) 

runApp(app) 

回答

0

我不知道是什麼原因導致的衝突,但解決的辦法是直接指定鏈接的主題。將theme = shinytheme("journal")替換爲theme = "http://bootswatch.com/journal/bootstrap.css"調整您正在使用的主題的名稱。

+0

我在這裏找到了答案:https://github.com/ebailey78/shinyBS/issues/62但想確保它被張貼在StackOverflow – Mark