Skip to content
This repository was archived by the owner on Jan 17, 2025. It is now read-only.
This repository was archived by the owner on Jan 17, 2025. It is now read-only.

Update input #13

Closed
Closed
@fmmattioni

Description

@fmmattioni

Hi John!

Thanks a lot for this package. I was previously using rintrojs and now that I am updating a shiny app, I decided to give cicerone a try. It is much easier to use, and makes the code cleaner!

I have one question: would it be possible to update an input once the guide reaches a specific input? For example, this is what I would do in rintrojs:

library(shiny)
library(rintrojs)

ui <- fluidPage(
  br(),
  br(),
  
  introjsUI(),
  
  shinyWidgets::switchInput(
    inputId = "demo_mode",
    size = "mini",
    onStatus = "success", 
    offStatus = "danger"
  ),
  
  numericInput(
    inputId = "input_1", 
    label = "Label numeric input:", 
    value = 0
  )
)

server <- function(input, output, session){
  
  steps_intro <- reactive(
    data.frame(
      element = "#input_1",
      intro = "Here you can choose a number."
    )
  )
  
  observe({
    req(input$demo_mode)
    
    rintrojs::introjs(
      session,
      options = list(steps = steps_intro()),
      events = list(
        onchange = I(
          "if (this._currentStep==0) {
          $('#input_1').val(50);
          Shiny.onInputChange('input_1', 50);
          }
          "
        ))
    )
  })
}

shinyApp(ui, server)

Thanks in advance!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions