I want add js to shiny.(hyperlink from one datatable to another in shiny)

library(shiny)
library(DT)
ui <- fluidPage(
  tabsetPanel(
    tabPanel("One",
             DT::dataTableOutput("test1")
    ),
    tabPanel("two",
             selectInput("select", h3("SELECT"), 
                         choices = c(0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10), selected = 1)
    )))
server <- function(input, output, session) {
  df <- reactive({
    cbind(seq_len(nrow(mtcars)),mtcars)
  })
  output$test1 <- DT::renderDataTable({
    df()
  },rownames=FALSE,options=list(dom="t"),
  callback=JS(
    'table.on("click.dt", "tr", function() {
    
    tabs = $(".tabbable .nav.nav-tabs li a");
    var data=table.row(this).data();
    
    document.getElementById("select").value=data[0];
    Shiny.onInputChange("select",data[0]);
    $(tabs[1]).click();
    table.row(this).deselect();})'
  ))
}
shinyApp(ui = ui, server = server)

I want make a hyperlink from one datatable to another in shiny by the same id. I have found similiar code and tried to revised it. But it doesn't work. Can someone tell me how to fix it? Thank you.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.