激活链接后,我正在使用Javascript在侧边栏菜单项中为SVG着色。它正在按要求工作。但这打破了侧边栏功能。我的意思是,当我单击侧边栏菜单时,它不会显示附加到选项卡项目的内容。如果我删除整个JS,它将起作用。
library(shinydashboard)
# User Interface
ui <-
dashboardPage(
dashboardHeader(title = "Basic Use of JS and CSS"),
dashboardSidebar(
sidebarMenu(
menuItem(
text = "Overview",
tabName = "summary",
icon = icon("home")
),
menuItem(
text = "REOs Stock",
tabName = "reo",
icon = icon("table")
)
)),
dashboardBody(
tags$head(
tags$script(HTML("
$(document).ready(function() {
$('svg').addClass('svg-outline')
$('.side-menu li.active .svg-outline').addClass('svg-outline2')
$('.side-menu li.active a').attr('aria-expanded','true')
$('.side-menu li').on('click', function() {
if ($('.side-menu li').hasClass('active')) {
$('.side-menu li.active .svg-outline').removeClass('svg-outline2')
$('.side-menu li.active').removeClass('active')
}
$(this).addClass('active')
$('.side-menu li.active .svg-outline').addClass('svg-outline2')
})
});
"))),
tabItems(
tabItem(
"summary", box(p("1st tab"))),
tabItem(
"reo", box(p("2nd tab"))
))
))
server = function(input, output) { }
runApp(list(ui = ui, server = server), launch.browser =T)