Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Example get-input-changed-info failing #13

Open
fernandoroa opened this issue Nov 13, 2023 · 1 comment
Open

Example get-input-changed-info failing #13

fernandoroa opened this issue Nov 13, 2023 · 1 comment

Comments

@fernandoroa
Copy link

When running

OSUICode::run_example(
  "shiny-events/get-input-changed-info",
  package = "OSUICode"
)

or its code in: https://unleash-shiny.rinterface.com/shiny-input-gems.html?q=get-input-changed-info%22#invoke-js-events

The browsers complaint about too much recursion, so, it does not work

R version 4.3.2 (2023-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 23.04

Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.11.0
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.11.0

locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_GB.UTF-8 LC_COLLATE=en_US.UTF-8
[5] LC_MONETARY=en_GB.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=en_GB.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C

time zone: America/Sao_Paulo
tzcode source: system (glibc)

attached base packages:
[1] stats graphics grDevices utils datasets methods base

other attached packages:
[1] shiny_1.7.5

@fernandoroa
Copy link
Author

Working code, as in shinyMobile:

library(shiny)

ui <- fluidPage(
  tags$script(
    HTML("
      $(document).on(
        'shiny:inputchanged',
        function(event) {
        var type;
        if (event.binding !== null) {
            type = event.binding.name !== undefined ? event.binding.name.split(\".\")[1] : \"NA\";
            Shiny.setInputValue(\"last_changed\", {
                name: event.name,
                value: event.value,
                type: type
            });
        }
      });"
    )),
  textInput("test", "Test"),
  verbatimTextOutput("last_changed2")
)

server <- function(input, output) {
  output$last_changed2 <- renderPrint(input$last_changed)
}

shinyApp(ui, server)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant