Including jQuery in Shiny Dashboard
Asked Answered
G

1

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?

Gurolinick answered 1/12, 2016 at 14:15 Comment(4)
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.Bearce
@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.Gurolinick
I writing from my mobile, did you check the versions?Bearce
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?).Dael
P
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"),
        ...
      ),
    ...
)
Protohistory answered 12/9, 2022 at 8:57 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.