I'm trying this because I also have a situation where I have an existing tabsetPanel with some tabPanels in it and I want to dynamically add more tabPanels and I'm brainstorming how I can accomplish this without the use of javascript.
----------------------------------------------------------------
library(shiny)
ui <- fluidPage(
div(actionButton("trial2", "Add tabset panel - trial 2")),
tags$div(id = "placeholder2")
)
server <- function(input, output, session) {
observeEvent(input$trial2, {
mytabs =
tabsetPanel(id='tabs2',
lapply(1:2, function(x){
tabPanel(id=paste0('tab2',x), value=paste0('value',x), title=paste0("Tab2 ", x),
fluidRow(
div(id=paste0("div2",x),
checkboxGroupInput(
paste0("checkbox2", x) ,
"Choose",
choices = c('One','Two','Three'),
inline = TRUE
))
)
)
})
)
print(mytabs)
insertUI(selector = '#placeholder2', where = "afterBegin", mytabs)
})
}
shinyApp(ui = ui, server = server)
----------------------------------------------------------------
The output of mytabs is:
<div class="tabbable">
<ul class="nav nav-tabs shiny-tab-input" id="tabs2">
<li class="active">
<a href="#tab-9514-1" data-toggle="tab"></a>
</li>
</ul>
<div class="tab-content">
<div class="tab-pane" title="Tab2 1" data-value="value1" id="tab21">
<div class="row">
<div id="div21">
<div id="checkbox21" class="form-group shiny-input-checkboxgroup shiny-input-container shiny-input-container-inline">
<label class="control-label" for="checkbox21">Choose</label>
<div class="shiny-options-group">
<label class="checkbox-inline">
<input type="checkbox" name="checkbox21" value="One" />
<span>One</span>
</label>
<label class="checkbox-inline">
<input type="checkbox" name="checkbox21" value="Two" />
<span>Two</span>
</label>
<label class="checkbox-inline">
<input type="checkbox" name="checkbox21" value="Three" />
<span>Three</span>
</label>
</div>
</div>
</div>
</div>
</div>
<div class="tab-pane" title="Tab2 2" data-value="value2" id="tab22">
<div class="row">
<div id="div22">
<div id="checkbox22" class="form-group shiny-input-checkboxgroup shiny-input-container shiny-input-container-inline">
<label class="control-label" for="checkbox22">Choose</label>
<div class="shiny-options-group">
<label class="checkbox-inline">
<input type="checkbox" name="checkbox22" value="One" />
<span>One</span>
</label>
<label class="checkbox-inline">
<input type="checkbox" name="checkbox22" value="Two" />
<span>Two</span>
</label>
<label class="checkbox-inline">
<input type="checkbox" name="checkbox22" value="Three" />
<span>Three</span>
</label>
</div>
</div>
</div>
</div>
</div>
tab-9514-1 tab-pane active
</div>
</div>
--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shiny-discuss/a79b16d1-cfb8-41d1-92c8-d3a177a66c26%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.