m45ha
m45ha

Reputation: 405

tabItem in shinydashboard not updating

I am trying to get my UI I have two tabs but the content of both are visible when i run the tab and the content in the body does not change when switching between tabs.

This is a "textbook" example, so I am totally puzzled. I am counting all my brackets which I see is the common issue.

This is my ui.r and nothing i have the default server.r

library(shiny)
library(shinydashboard)

#--------
#--------
#individual components

#--------
#sidebar

sidebar<-dashboardSidebar(
  sidebarMenu(
    menuItem("1", tabName="Item1"),
    menuItem("2", tabName="Item2")


  )#sidebarMenu
)#dashboardSidebar

#--------

#body

body<- dashboardBody(
  tabItem(tabName='Item1',
          h2("item1 content")
          ),#tabItem

  tabItem(tabName="Item2",
          h2("item2 content")
          )#tabItem


)#dashboardBody

#--------
#--------
#MAIN

# Define UI for application
shinyUI(

dashboardPage
(
  dashboardHeader(title="hi there"),
  sidebar,
  body

) #dashboardPage

) #shinyUI

Upvotes: 0

Views: 102

Answers (1)

m45ha
m45ha

Reputation: 405

and mm... stupid me missing.. tabItems

body<- dashboardBody(
  tabItems( #THIS!!!
  tabItem(tabName='Item1',
          h2("item1 content")
          ),#tabItem

  tabItem(tabName="Item2",
          h2("item2 content")
          )#tabItem

  )#tabItems <- THIS!!!


)#dashboardBody

#--------
#--------
#MAIN

# Define UI for application
shinyUI(

dashboardPage
(
  dashboardHeader(title="hi there"),
  sidebar,
  body

) #dashboardPage

) #shinyUI

Upvotes: 0

Related Questions