Hello, this is a minimum example of the problem, and I see that the runjs doesn't run.
runjs('document.getElementById("top").scrollIntoView();')
Do you have an idea to make it functionnal ?
library(shiny)
library(shinyjs)
library(shinydashboard)
library(DT)
library(shinyFeedback)
ui <- fluidPage(
fileInput("file1", "Choose CSV File",
accept = c(
"text/csv",
"text/comma-separated-values,text/plain",
".csv")),
checkboxInput("header1", "Header", TRUE),
tags$hr(),
fileInput("file2", "Choose CSV File",
accept = c(
"text/csv",
"text/comma-separated-values,text/plain",
".csv")),
checkboxInput("header2", "Header", TRUE),
tags$div(id="top", "I'm at the top, javascript can scroll me into view"),
tags$br(),
tags$br(),
tags$br(),
tags$br(),
tags$br(),
tags$br(),
tags$br(),
tags$br(),
tags$br(),
tags$br(),
tableOutput("contents1"),
tableOutput("contents2"),
tags$br(),
tags$br(),
tags$br(),
tags$br(),
tags$br(),
tags$br(),
tags$br(),
tags$br(),
tags$br(),
tags$div(id="bottom", "I'm at the bottom, javascript can scroll me into view"),
)
server <- function(input, output) {
observeEvent(input$file1, {
runjs('document.getElementById("bottom").scrollIntoView();')
})
observeEvent(input$file2, {
runjs('document.getElementById("top").scrollIntoView();')
})
output$contents1 <- renderTable({
inFile <- input$file1
if (is.null(inFile))
return(NULL)
read.csv(inFile$datapath, header = input$header1)
})
output$contents2 <- renderTable({
inFile <- input$file2
if (is.null(inFile))
return(NULL)
read.csv(inFile$datapath, header = input$header2)
})
}
shinyApp(ui, server)