library(shiny)
library(shinyjs)
library(shinyWidgets)
ui<- fluidPage(titlePanel("Application"),
useShinyjs(),
fluidRow(column( width = 8,
panel(style = "overflow-y:scroll; max-height: 300px; position:relative; align: centre",
textInput("message", label = "",placeholder = "Type your message here."),
actionButton("send", "Send"),
div(id="bottom", "I'm at the bottom, javascript can scroll me into view"),
heading = "Education", status = "primary")
)
))
server<- function(input, output, session)
{
clearInput<- function()
{
updateTextInput(session,"message", value = "")
}
observeEvent(input$send,{
#Case 1
insertUI(
selector = "#message",
where = "beforeBegin",
ui=div(class="registration",
div(class="bubble",
wellPanel(
p("Please enter your Name")
)
)),
,
immediate = TRUE)
if(grepl("^[a-zA-Z][a-zA-Z ]+[a-zA-Z]$",input$message, perl=T))
{
insertUI(
selector = "#message",
where = "beforeBegin",
ui=div(class="registration",
div(class="bubble",
wellPanel(
p(input$message),
p("Please enter your Number")
)
)),
immediate = TRUE)
clearInput()
}
runjs('
document.getElementById("bottom").scrollIntoView();
')
})
}
shinyApp(ui,server)