Catch id of current selected PivotItem #90
-
|
Hi, Thanks a lot for this library, the user interface is awesome. I've been working today on a page using a Pivot, with PivotItems. I've tried these methods, not any works :
The id of a pivot item looks like this : "Pivot1606-Tab0", I can't figure out how to catch this ID to manipulate the UI on the server side. I havn't done a reprex, let me know if it could help to understand my problem. Thanks a lot ! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 10 replies
-
|
Hi @BorisDelange! Thanks for your question and praise 🙂 You can get the clicked tab using library(shiny)
library(shiny.fluent)
library(glue)
setClickedId <- function(inputId) {
JS(glue("item => Shiny.setInputValue('{inputId}', item.props.id)"))
}
shinyApp(
ui = tagList(
textOutput("text"),
Pivot(
onLinkClick = setClickedId("currentTab"),
PivotItem(id = "tab1", headerText = "Apples"),
PivotItem(id = "tab2", headerText = "Bananas")
)
),
server = function(input, output) {
output$text <- renderText(input$currentTab)
}
) |
Beta Was this translation helpful? Give feedback.
-
|
I have been trying to use this solution with the Rhino framework approach and the onLinkClick callback is executed when the Shiny app is initially rendered, but then does not fire when I click on the different links. Here is the code that I am using: I am using version R 4.2.0 with Shiny 1.7.3 and shiny.fluent 0.3.0. Any help would be greatly appriciated. Edit: Just realized that this seems related to the fact that I have wrapped the ui in a call to |
Beta Was this translation helpful? Give feedback.
Hi @BorisDelange! Thanks for your question and praise 🙂
You can get the clicked tab using
onLinkClickprop the following way: