【问题标题】:Delaying and expiring a shinyBS::bsTooltip延迟和过期一个 shinyBS::bsTooltip
【发布时间】:2018-05-08 16:51:57
【问题描述】:

是否可以延迟工具提示并在几秒钟后过期?

require(shiny)
require(shinyBS)

shinyApp(ui = fluidPage(
  shinyjs::useShinyjs(),
  bsTooltip(id = 'input', title = "Lets delay this appearing for 1s and force disappear after 5s", 
    placement = "bottom", trigger = "hover", options = list(delay = list(show=1000, hide=3000))),

  sidebarLayout(
    sidebarPanel(
      selectInput(inputId = 'input', label = 'input', choices = c('cats','dogs'))
    ),
    mainPanel()
  )
)
, server = function(input, output){})

【问题讨论】:

    标签: r shiny shinybs


    【解决方案1】:

    shinyBS::bsTooltip 无法正确序列化 https://github.com/ebailey78/shinyBS/blob/shinyBS3/R/Tooltips_and_Popovers.R#L129 中嵌套的 options 列表

    options 对象最终看起来像 { delay: "list(show = 1000, hide = 3000)" }

    不幸的是,shinyBS 似乎不再维护,或者值得提交修复。

    我会建议一个解决方法 - 使用 shinyBS::addTooltip 可以正确序列化 options

    require(shiny)
    require(shinyBS)
    
    shinyApp(
      ui = fluidPage(
        # shinyjs::useShinyjs(),
        shinyBS:::shinyBSDep,
    
        sidebarLayout(
          sidebarPanel(
            selectInput(inputId = 'input', label = 'input', choices = c('cats','dogs'))
          ),
          mainPanel()
        )
      ),
      server = function(input, output, session) {
        addTooltip(session, id = 'input', title = "Lets delay this appearing for 1s and force disappear after 5s",
                   placement = "bottom", trigger = "hover", options = list(delay = list(show=1000, hide=3000)))
      }
    )
    

    或者直接使用 Bootstrap。

    【讨论】:

    • 干杯,格雷格,这将完成这项工作。
    【解决方案2】:

    我使用了tipify。所以我的代码是这样的:

    tipify(
      element,
      title = "some title",
      options = list("delay" = 1000)
    )
    

    问题是:延迟确实是数字,但函数 createTooltipOrPopoverOnUI (https://github.com/ebailey78/shinyBS/blob/shinyBS3/R/Tooltips_and_Popovers.R) 会将引号括起来所有参数:

    options = paste0("{'", paste(names(options), options, sep = "': '", collapse = "', '"), "'}")
    

    所以我这样做了:我并不为此感到自豪,但它奏效了:

    options = list("delay': 1000, 'it" = "sucks")
    

    【讨论】:

      猜你喜欢
      • 2020-02-07
      • 1970-01-01
      • 2011-11-29
      • 1970-01-01
      • 2017-01-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-06-02
      相关资源
      最近更新 更多