-
Notifications
You must be signed in to change notification settings - Fork 8
'on_highlighted' argument is triggered at the start of the tour #15
Comments
I have an error when I run your code, I think you forgot to put |
This actually puzzeld me. In my working app it also complained about it and I had to include it as you said. Just in case I have included it again as suggested. |
I found the issue(s). There are multiple things at play here. First, the Second, Third, I'm not familiar with shinyjs' I have thus added two arguments to pass to steps:
Both take JavaScript function (R character strings), the first is triggered just before the element is highlighted, the second is triggered when the next button is clicked. This will require installing the github version. install.packages("remotes")
remotes::install_github("JohnCoene/cicerone") The code below works, the only change is using library(shiny)
library(shinydashboard)
library(cicerone)
library(shinyjs)
jscode <- "
shinyjs.collapse = function(boxid) {
$('#' + boxid).closest('.box').find('[data-widget=collapse]').click();
}
"
ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(
useShinyjs(),
extendShinyjs(text = jscode, functions = "collapse"),
use_cicerone(),
div(
box(
textInput(
inputId = "text1",
label = "Text 1",
value = "",
placeholder = "Text 1"
),
textInput(
inputId = "text2",
label = "Text 2",
value = "",
placeholder = "Text 2"
),
textInput(
inputId = "text3",
label = "Text 3",
value = "",
placeholder = "Text 3"
),
)
),
box(
id = "super_box",
title = "Expandable box",
solidHeader = TRUE,
collapsible = TRUE,
collapsed = TRUE,
"Stuff inside the box!",
textInput(
inputId = "text4",
label = "Text 4",
value = "",
placeholder = "Text 4"
)
),
actionButton(inputId = "tutorial", label = "Tutorial"),
actionButton(inputId = "expand", label = "Expand")
)
)
server <- function(input, output) {
observeEvent(input$expand, {
js$collapse("super_box")
})
observeEvent(input$tutorial, {
Cicerone$
new()$
step(
el = "text1",
title = "Text 1",
class = "popover",
description = "Info 1"
)$
step(
el = "text2",
title = "Text 2",
class = "popover",
description = "Info 2"
)$
step(
el = "text3",
title = "Text 3",
class = "popover",
description = "Info 3"
)$
step(
el = "text4",
title = "Expand box",
class = "popover",
description = "Is it expanded?",
on_highlight_started = "function(){
$('#super_box').closest('.box').find('[data-widget=collapse]').click();
}"
)$
init()$
start()
})
}
shinyApp(ui, server) |
I'll assume this fixed the issue and close this, feel free to reopen if it is not the case. |
Sorry man, crazy week. Could not test it yet but I will let you know soon if I face any issue. Thanks for that. |
No worries |
Worked perfectly - both the 'on_highlight_started' and the 'on_next'. Many thanks again. |
I am running a Cicerone tour as a tutorial of my shinydashboard app UI. The idea is to walk the user thru the various inputs in the interface. Some of these inputs are present inside boxes which are presumably collapsed at the start of the tour, my goal is to use the 'on_highlighted' argument to trigger a shinysj toggle command at a given specific step().
The toggle command works fine independently. The Cicerone tour works fine independently. But the shinyjs is not trigerred at the specific step() but rather at the start of the tour (i.e. before first step()).
Below an example:
The text was updated successfully, but these errors were encountered: