Is there a way to hide/disable the `Close` button on a `bsModal` window?

杀马特。学长 韩版系。学妹 提交于 2019-12-01 20:59:35

This should do it

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){

    }
  )
}

Alternatively to @PorkChop's solution, you can write the modal without 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("&times;")
            )
          ),
          #### 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){

  }
)
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!