-
-
Save ColinFay/d9e13d6e04ccd8eb786c29e0326d074e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
library(shiny) | |
# MODULE UI | |
customInputUI <- function(id) { | |
ns <- NS(id) | |
verbatimTextOutput(ns("debug")) | |
} | |
# MODULE SERVER | |
# Render the custom shiny input binding | |
customInput <- function(input, output, session) { | |
# This should return "This is a test" from script.js....? | |
output$debug <- renderPrint({ input$testing }) | |
} | |
ui <- fixedPage( | |
h2("Shiny.setInputValue Inside Module"), | |
customInputUI("custom_input"), | |
# This is where we assign the custom binding | |
tags$script( | |
'$(document).on("shiny:connected", function(event) { | |
Shiny.setInputValue("custom_input-testing", "This is a test"); | |
});' | |
) | |
) | |
server <- function(input, output, session) { | |
df <- callModule(customInput, "custom_input") | |
} | |
shinyApp(ui, server) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment