I would like to exit an option (menuSubItem
) when I click outside of this field, but the option does not disappear when I click outside. I tried a solution with CSS, but it didn't work! My code:
library(shiny)
library(shinydashboard)
header <- dashboardHeader(title = "Dashboard", titleWidth = 320)
sidebar <- dashboardSidebar(
width = 320,
sidebarMenu(
menuItem(
text = "A1"
),
menuItem(
text = "A2",
menuSubItem(
text = "AA1"
),
menuSubItem(
text = "AA2"
),
menuSubItem(
text = "AA3"
)
)
)
)
body <- dashboardBody()
ui <- dashboardPage(header = header, sidebar, body)
server <- function(input, output) {
}
shinyApp(ui, server)
I would like to click outside of A2
and have it (A2
) close the dropdown menu when this click is done.
I tried insert this code in body:
body <- dashboardBody(
HTML(
"<script>
$(function() {
$(document).on('click', function() {
$('.skin-blue .treeview-menu>li>a').slideUp();
});
});
</script>"
)
)
But don't work.