Custom javascript in rmarkdown application does not work

rmarkdown
shiny
flexdashboard

#1

Hi, I am trying to add custom javascript to my application build on rmarkdown, shiny,flexdashboard.
Here is simple html working example about the wanted funkcionality - if I click on image, it appears in lightbox:

But if I create the same in rmarkdown document with shiny and flex_dashboard, it does not work.
I included javascript lightbox code in last chunk according to advice in this article - https://shiny.rstudio.com/articles/packaging-javascript.html

Here is rmarkdown code:


title: "TYPOVÁ OPATŘENÍ PRO OMEZENÍ SUCHA"
output:
flexdashboard::flex_dashboard:
orientation: columns
vertical_layout: fill
css: 'stylitka.css'
#css: 'http://www.dibavod.cz/data/typova_opatreni/javascript/jsonlylightbox/styles.css'
runtime: shiny


library(flexdashboard)
library(shiny)


renderUI({

cesta<-"http://www.dibavod.cz/data/sucho/obr_opatreni/MVN.png"

img(class="jslghtbx-thmb", src = cesta, "data-jslghtbx"= cesta)

})    



//here I placed complete javascript lightbox code from these sources:

//http://www.dibavod.cz/data/typova_opatreni/javascript/jsonlylightbox/lightbox.js
//http://www.dibavod.cz/data/typova_opatreni/javascript/jsonlylightbox/lightbox_ini.js
    

Thanks a lot for any advice !