Git Product home page Git Product logo

Comments (1)

gadenbuie avatar gadenbuie commented on May 28, 2024

Similar behavior happens for insertTab() and removeTab().

library(shiny)

ui <- fluidPage(
  actionButton('insertBtn', 'Insert'),
  actionButton('removeBtn', 'Remove'),
  tabsetPanel(
    id = "tabs",
    tabPanel(
      "Base",
      "Base tab content. Other tabs will have their tab-specific text."
    )
  )
)

server <- function(input, output) {

  ## keep track of elements inserted and not yet removed
  inserted <- c()

  observeEvent(input$insertBtn, {
    count <- input$insertBtn
    # give the inserted element a unique id so we can remove it later
    new_tab_title <- paste('Tab', count)

    # push a new element in to the app
    insertTab(
      inputId = "tabs",
      tabPanel(
        title = new_tab_title,
        paste("Content for", new_tab_title)
      )
    )
    inserted <<- c(inserted, new_tab_title)
  })

  observeEvent(input$removeBtn, {
    # pop last inserted tab out of the app
    removeTab(
      inputId = "tabs",
      target = inserted[length(inserted)]
    )
    # and remove it from the list of inserted elements
    inserted <<- inserted[-length(inserted)]
  })

}

shinyApp(ui, server)

With client error console

Kapture.2023-11-28.at.12.06.49.mp4

shiny 1.8.0

Kapture.2023-11-28.at.12.06.08.mp4

from shiny.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.