bsModal
应用中的shiny
窗口附带默认Close
按钮。有没有办法可以禁用?我试图在SO上查找类似的问题,但没有找到符合我要求的问题。我认为,如果用户可以使用右上角X
按钮关闭窗口,则根本不需要另一个Close
按钮。请指教。以下可重现的代码将生成一个样本bsModal
窗口以了解我的问题。
library(shiny)
library(shinyBS)
if(interactive()){
shinyApp(
ui <- fluidPage(
actionButton("open", "Open"), #action button to trigger the modal window.
bsModal("id1", "Box 1", "open", size = "small",
HTML(paste("A simple modal window."))
)
),
server <- function(input,output,session){
}
)
}
答案 0 :(得分:5)
这应该这样做
library(shiny)
library(shinyBS)
if(interactive()){
shinyApp(
ui <- fluidPage(
actionButton("open", "Open"), #action button to trigger the modal window.
bsModal("id1", "Box 1", "open", size = "small",
HTML(paste("A simple modal window.")),
tags$head(tags$style("#id1 .modal-footer{ display:none}"))
)
),
server <- function(input,output,session){
}
)
}
答案 1 :(得分:1)
除了@ PorkChop的解决方案,您可以在不使用shinyBS
的情况下编写模式:
library(shiny)
shinyApp(
ui <- fluidPage(
tags$button(class="btn btn-default",
"data-toggle"="modal", "data-target"="#simplemodal",
"Open modal"),
tags$div(
id = "simplemodal",
class="modal fade", role="dialog",
tags$div(
class="modal-dialog",
tags$div(
class="modal-content",
#### Header ####
tags$div(
class="modal-header",
tags$button(
type="button", class="close", "data-dismiss"="modal",
HTML("×")
)
),
#### Body ####
tags$div(
class="modal-body",
HTML("A simple modal window")
),
#### Footer (remove it if you want) ####
tags$div(
class="modal-footer",
tags$button(
type="button", class="btn btn-default", "data-dismiss"="modal",
"Close"
)
)
)
)
)
),
server <- function(input,output,session){
}
)