carlganz / rintrojs

Wrapper for the Intro.js library
http://rintrojs.carlganz.com/
GNU Affero General Public License v3.0
133 stars 11 forks source link

generate hints dynamically #57

Open parthpatadiya opened 1 year ago

parthpatadiya commented 1 year ago

Using below code to generate hints from server side dynamically in r shiny app. but it's not working. basically i want to use hint with css element because i can't select sidebar toggle button in ui.r using infoBox().

hints <- data.frame(
    hint = c(
      "This is a sidebar button",
      "This is selectize filter. to remove item : first click on the item and click backspace from keyboard.",
      "This is select filter. you can select only one option at a time from the dropdown list",
      "This is Slider input filter. you can select the range of day by dragging from both end",
      "This is Date input filter. you can select the start and end date.",
      "This is Group checkbox list filter. you can check multiple options."
    )
    ,element = c(".sidebar-toggle",
                           "#country_nm_select-label",
                          "#status_select-label",
                          "#vac_arr_trgt_days_slider-label",
                          "#date_slider",
                          "#type_of_vaccine_checkbox")

  )

  hintjs(session, options = list(hints=hints))
parthpatadiya commented 1 year ago

adding hints column in steps also not showing any hints

library(shiny)
library(rintrojs)

ui <- shinyUI(fluidPage(
      introjsUI(),
      mainPanel(
        textInput("intro","Enter an introduction"),
         actionButton("btn","Press me")
      )
   )
)

server <- shinyServer(function(input, output, session) {

  steps <- reactive(data.frame(element = c(NA,"#btn"),
                               intro = c(input$intro,"This is a button"),
                               hint  = c("hint1","hint2")))

  observeEvent(input$btn,{
    introjs(session,options = list(steps=steps()))

  })

})

# Run the application 
shinyApp(ui = ui, server = server)