I would like to integrate a JS code to a Shiny application to load a TradingView JS widget.
The problem is when the app is loading, the selector input disappears and the TradingView widget replaces the whole UI, I do not know why.
library(shiny)
library(shinyjs)
jsCode <- 'shinyjs.pageCol = function(para){new TradingView.widget( {"width": 640,"height": 400,"symbol": para,"interval": "D","timezone": "Etc/UTC","theme": "light", "style": "1",
                              "locale": "en", "toolbar_bg": "#f1f3f6","enable_publishing": false, "allow_symbol_change": true,"container_id": "tradingview_e9634"}  );}'
shinyApp(
  ui = fluidPage(
    div(selectInput("ticker", "Ticker:",
                c('NASDAQ:AMD', 'NASDAQ:TSLA', 'NASDAQ:GE'))),
    tags$head(HTML('<script type="text/javascript" src="https://s3.tradingview.com/tv.js"></script>')) ,
    useShinyjs(),
    div(extendShinyjs(text = jsCode, functions = c("pageCol")))
  ),
  server = function(input, output) {
    observeEvent(input$ticker, {
      js$pageCol(input$ticker)
    })
  }
)
 
    