简体   繁体   中英

shinyBS - remove tooltip when dragging

I'm using dragulaR to create draggable divs in Shiny, and added a tooltip using shinyBS to each div. I was wondering if it's possible to remove the tooltip (I tried adding jQuery from JQuery UI: remove Bootstrap tooltip on a draggable clone when drag starts? ) when dragging the div?

library(shiny)
library(dragulaR)
library(shinyBS)

makeElement <- function(data, name)
{
  div(style = "border-width:2px;border-style:solid;",
      drag = name,
      div(class = "active-title-row", id = name, name),
          bsTooltip(id = name, title = "Hover",
                    placement = "top", trigger = "hover"))
}

ui <- fluidPage(

  # Maybe something like this but it doesn't work
  tags$script(HTML(
    "$(function() {
    start: function(event, ui) {             
      $('#bsTooltip').hide();             
    });"
  )),

  titlePanel("Drag and drop elements with dragulaR"),

  fluidRow(style = "margin: 15px;",
           column(3,
                  h3("Drag from here:"),
                  div(id = "Available", style = "min-height: 600px;",
                      lapply(colnames(mtcars), makeElement, data = mtcars))
           ),
           column(3,
                  h3("Drop here:"),
                  div(id = "Model", style = "min-height: 600px;")
           )
  ),
  dragulaOutput("dragula")

)

server <- function(input, output) {

  output$dragula <- renderDragula({
    dragula(c("Available", "Model"))
  })

}

shinyApp(ui = ui, server = server)

by removing the title text in the makeElement function you'll be able to remove the "Hover" tooltip while dragging elements.

makeElement <- function(data, name)
{
  div(style = "border-width:2px;border-style:solid;",
      drag = name,
      div(class = "active-title-row", id = name, name),
      bsTooltip(id = name, title = "",
                placement = "top", trigger = "hover"))
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM