小编Pau*_*pen的帖子

Shiny:将焦点设置为 modalDialog 中的输入

我正在尝试将焦点集中在闪亮的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)

r shiny shinyjs

6
推荐指数
1
解决办法
702
查看次数

标签 统计

r ×1

shiny ×1

shinyjs ×1