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

后端 未结 2 1504
栀梦
栀梦 2021-01-21 01:52

A bsModal window in shiny app comes with a default Close button. Is there a way that can be disabled? I tried to look up on SO for similar

2条回答
  •  轮回少年
    2021-01-21 02:21

    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("×")
                )
              ),
              #### 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){
    
      }
    )
    

提交回复
热议问题