7

I work with Shiny Dashboard. I want to include jQuery in the App. However, when I add these lines

tags$script(src = "https://code.jquery.com/jquery-3.1.1.min.js")

the app breakes completely. The layout gets messed up, buttons are not clickable anymore and so forth. I can include jQuery in the "normal" Shiny App without these problems.

Does Shiny Dashboard forbid to include jQuery?

four-eyes
  • 10,740
  • 29
  • 111
  • 220
  • 1
    Isn't jquery already included in shiny. Open the app in a browser, take a look at the source to see which version is used. – Valter Beaković Dec 01 '16 at 14:19
  • @ValterBeaković thats what I thought. But when I exclude my line, the stuff I wrote with `jQuery` is not working. I thought so too, that shiny (dashboard) includes jQuery. However, when I use it without referencing to a `.js` file, it does not work properly. – four-eyes Dec 01 '16 at 14:23
  • I writing from my mobile, did you check the versions? – Valter Beaković Dec 01 '16 at 14:24
  • 4
    Possibly you have figured this out already, but I'll just say it anyway. Shiny uses jQuery 1.12.4 as of Aug. 2017. Introducing another version of jQuery would definitely require some tweaking (I heard there is a no-conflict mode?). – Yifeng Mu Sep 02 '17 at 00:47

1 Answers1

0

I had similar problem and solution was to include both .css and .js files in dashboardPage() like this (after putting them in www/ directory):

dashboardPage(
    ...
    body = dashboardBody(
      ...
      shiny::tags$head(
        ...
        tags$link(rel = "stylesheet", href = "jquery-ui.min.css"),
        tags$script(src = "jquery-ui.min.js"),
        ...
      ),
    ...
)