延迟和过期有光泽的BS :: bsTooltip

时间:2017-11-24 16:41:03

标签: r shiny shinybs

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

h = { "v1" => 1, "v2" => 2}
File.open("./out.dat","w") do |f| 
  h.each { |k,v| f.write("#{k}\t#{v}\n") }
end 

enter image description here

2 个答案:

答案 0 :(得分:2)

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

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

不幸的是,看起来glBS不再维护了,或者修复是值得提交的。

我会建议一种解决方法 - 使用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。

答案 1 :(得分:1)

我曾经给小费。所以我的代码就像:

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")