This is my MWE:
library(shiny)
ui <- fluidPage(
uiOutput("log"),
actionButton("test","Click")
)
server <- function(input, output,session) {
RV<-reactiveValues(myText=as.character())
observeEvent(input$test,{
text<-as.character()
for (i in 1:100) text<-paste0(text,"hello ",i,"\n")
RV$myText<-text
})
output$log<-renderUI({
sHtml<-paste0("<pre id=\"preLog\" style=\"width:100px;height:200px;overflow:auto\">",RV$myText,"</pre>")
print(HTML(sHtml))
})
}
shinyApp(ui = ui, server = server)
When I click on the button, the pre element is populated, but it shows the rows at the top. ¿How can I make it to automatically scroll to the bottom?
Thanks.!
Here is a way. I use
verbatimTextOutput, which generates apreelement.