0

I found the bsModal works as expected with fluidPage but not without it. Just click "View Table" button to see the difference.

The version with fluidPage:

library(shiny)
library(shinyBS)

shinyApp(
  ui =
    fluidPage(
      sidebarLayout(
        sidebarPanel(
          actionButton("tabBut", "View Table")
        ),

        mainPanel(
          bsModal("modalExample", "Data Table", "tabBut", size = "large",
                  "distTable")
        )
      )
    ),
  server =
    function(input, output, session) {}
)

The version without fluidPage, the only change is that the fluidPage is replaced by tagList:

library(shiny)
library(shinyBS)

shinyApp(
  ui =
    tagList(
      sidebarLayout(
        sidebarPanel(
          actionButton("tabBut", "View Table")
        ),

        mainPanel(
          bsModal("modalExample", "Data Table", "tabBut", size = "large",
                  "distTable")
        )
      )
    ),
  server =
    function(input, output, session) {}
)

Can anyboday help me explain what happened between bsModal and fluidPage?

Uwe Keim
  • 39,551
  • 56
  • 175
  • 291
Liang
  • 403
  • 1
  • 5
  • 14

1 Answers1

0

Because fluidPage is much, much more than a simple tagList.

tagList simply takes it arguments and concatenates them (expecting each argument to be some sort of HTML tag). fluidPage literally generates an entire HTML document with bootstrap dependencies.

Your first example is figuratively "build a house with basement, floor plan and attic" with sidebarLayout explaining the layout of floors and fluidPage being the house. Remove the fluidPage and you're trying to build a house with basement, floor plan and attic, but without the foundation, walls or roof.

MrGumble
  • 5,631
  • 1
  • 18
  • 33
  • Does it mean fluidPage will load all bsModal's dependencies? Would like to know what's the specific dependency? – Liang Mar 22 '19 at 07:01
  • `fluidPage` does not know of its childrens' dependencies, so it does not load `bsModal`s. `bsModal` loads its own dependencies. Try typing in the R console `fluidPage`, `tagList` and `bsModal`, without parenthesis, to view their definitions and look for `attachDependencies`. For some of the functions you might have to look up the function they are calling to elude their inner workings. – MrGumble Mar 22 '19 at 07:10