I want to create a draggable shiny::modalDialog() with just shiny and JS/jQuery and without other packages like shinyjqui.
Following the example from here it should be easily achievable with the jQuerys .draggable sine the modalDialog created when clicking on the actionButton has bootstrap class modal, but somehow it does not work. Does anybody has some advice?
library(shiny)
library(bslib)
ui = fluidPage(theme = bs_theme(version = 5),
div(style = "margin: 4rem; display: flex; justify-content: center;",
div(
actionButton(inputId = "action", label = "open modal"))),
tagList(
tags$script(HTML('$(".modal").draggable({
handle: ".modal-header"
});')))
)
server = function(input, output, session){
observeEvent(input$action, {
showModal(
modalDialog(
title = "Modal", easyClose = T))
})
}
shinyApp(ui, server)