Hi Dean,
Is it possible to refresh(reload application) webpage based on click event on the tabset panel ? I have a home tab on my navbar page, whenever i click that tab the whole system need to get refreshed. Currently i am using an action button to do it . i tried to use shinyjs in tabpanel but its not working. Not sure how to handle it.
You can do something like this
library(shiny)
library(shinyjs)
jscode <- "shinyjs.refresh = function() { location.reload(); }"
shinyApp(
ui = tagList(
useShinyjs(),
extendShinyjs(text = jscode, functions = "refresh"),
navbarPage(
"test",
id = "navbar",
tabPanel(title = "tab1", "tab 1"),
tabPanel(title = "tab2", "tab 2"),
tabPanel(title = "Refresh", value = "refresh")
)
),
server = function(input, output, session) {
observe({
if (input$navbar == "refresh") {
js$refresh();
}
})
}
)
Thanks I understood it but my page is like a google search page with a home tab whenever i open it keeps on refreshing. The idea was good thanks.
You can do something like this
library(shiny) library(shinyjs) jscode <- "shinyjs.refresh = function() { location.reload(); }" shinyApp( ui = tagList( useShinyjs(), extendShinyjs(text = jscode, functions = "refresh"), navbarPage( "test", id = "navbar", tabPanel(title = "tab1", "tab 1"), tabPanel(title = "tab2", "tab 2"), tabPanel(title = "Refresh", value = "refresh") ) ), server = function(input, output, session) { observe({ if (input$navbar == "refresh") { js$refresh(); } }) } )
Hello, If I only want to refresh a certain tab, not the "location", how can I access the TabName, please?
Most helpful comment
You can do something like this