我正在尝试将焦点集中在闪亮的textInput地方modalDialog。我在用shinyjs。根据shinyjs文档的指导,我想出了以下代码,但它没有达到我的预期:
library(shiny)
library(shinyjs)
jscode <- "
shinyjs.refocus = function(e_id) {
document.getElementById(e_id).focus();
}"
# Define UI for application that draws a histogram
ui <- fluidPage(
shinyjs::useShinyjs(),
shinyjs::extendShinyjs(text = jscode, functions = "refocus"),
# Application title
titlePanel("Old Faithful Geyser Data"),
# Sidebar with a slider input for number of bins
sidebarLayout(
sidebarPanel(
sliderInput("bins",
"Number of bins:",
min = 1,
max = 50,
value = 30),
actionButton("show", "Show Modal")
),
# Show a plot of …Run Code Online (Sandbox Code Playgroud)