RinteRface / argonDash

argon dashboard template
https://rinterface.github.io/argonDash/
138 stars 37 forks source link

Access current tab selection #7

Closed ghost closed 5 years ago

ghost commented 5 years ago

Hi, I tried to access the current tab selection by running input$sidebar, sidebar being the id of the sidebar used in argonDashSidebar but it did not work. Is this a bug?

DivadNojnarg commented 5 years ago

Hi,

There is no input associated with the sidebar or tabCard. Therefore this behavior is expected. For the moment you could create a JavaScript code to set a Shiny.onInputChange. It won’t work with Shinytest.

ghost commented 5 years ago

Thanks for the suggestion, the workaround works.

OGuggenbuehl commented 5 years ago

Would you be willing to post an example of the workaround?

ghost commented 5 years ago

Hey @OGuggenbuehl,

Basically I added the following JS code to argonDashBody

tags$script( "$(document).on('click', function(event) {
              Shiny.onInputChange('activeTab', $('.active').data().value);});")

Which creates input$activeTab containing the id of the active tab.

This trick only works after the user clicks anywhere on page, I couldn't get Shiny.onInputChange to work without that.

Let me know if you still need help.