rstudio / shinydashboard

Shiny Dashboarding framework

Home Page:https://rstudio.github.io/shinydashboard/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Inline JavaScript not working within dashboardBody()

chuansunaacg opened this issue · comments

Hi all,

I used the example to create a redirect page for my Shiny app. The code works under fluidpage(), but doesn't work for our app under dashboardBody(). I'm familiar with R but not Javascript, so couldn;t really figure out why.

Below is a minimal reproducible example (of Javascript not working within dashboardBody()): (test2.html can be any html, I just use some text)

library(shiny)
library(shinydashboard)

ui <- dashboardPage(
dashboardHeader(),
dashboardSidebar(),
dashboardBody(
tags$script("
$(function() {$(document).on('shiny:disconnected shiny:error', function(event) {
$('.container-fluid').load('./test.html');
}) });
"),
actionButton("disconnect", "Disconnect the app")
)
)
server <- function(input, output, session) {
observeEvent(input$disconnect, {
session$close()
})
}
shinyApp(ui, server)