uncaught exception: Duplicate binding for ID

334 views
Skip to first unread message

Christoph Knapp

unread,
Apr 7, 2015, 11:36:30 PM4/7/15
to shiny-...@googlegroups.com
Hi,
this topic has been covered in several threads but I don't think my problem has come up yet. I get an "uncaught exception: Duplicate binding for ID xxx" javascript error in my application but I was very careful not to use any duplicate ids. I recovered the problem in a greatly simplified version of my application. I uploaded my files.

The application has two tabpanels and one navbarmenu in a navbar. The first (Start) just displays some text and what is selected in tabpanel two (Select). The third is named (Get javascript error) and works fine if something was selected in panel 2. The error is produced when something else is selected in the "Select" panel and the user returns to the "Get javascript error" panel. The select menu is still changeable but the verbatimTextOutput does not update anymore. and in the javascript console this error is displayed with the id of the verbatimTextOutput listed as duplicate id.

Thanks in advance

Christoph

 
ui.R
server.R
global.R

Winston Chang

unread,
Apr 8, 2015, 1:34:12 PM4/8/15
to Christoph Knapp, shiny-discuss
I don't get the Javascript error when I run your app. Note that I'm using the latest development version of Shiny.

As for why the choice value isn't updating for you, it's because this is what you're using to update the value:

  observe({
    selected.choice <<- input$select 
  })


And then you access `selected.choice` from various renderUI functions, like this:

  output$text.main.outA1 = renderPrint({
    cat("This is A, with selection ",input$A, " and selected choice: ",selected.choice)
  })


When input$select changes, it won't invalidate that renderPrint() -- it will only invalidate the observer.

If you want changes in input$select to cause the renderPrint() to re-execute, you need to do one of the following:

* Access input$select directly in renderPrint().

* Use a reactive expression, like this:
    selected_choice <- reactive( input$select )
  and then access selected_choice() from your renderPrint().

* Use a reactiveValues object and assign a value into it, in the observe(). Then access it in the renderPrint().

-Winston







--
You received this message because you are subscribed to the Google Groups "Shiny - Web Framework for R" group.
To unsubscribe from this group and stop receiving emails from it, send an email to shiny-discus...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/shiny-discuss/dd005437-7cc6-4705-8d7e-fd259525f6b9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Greg L

unread,
Apr 8, 2015, 3:45:45 PM4/8/15
to shiny-...@googlegroups.com
I also didn't get a javascript error, (using shiny 0.11.1). but man, even simplified, your code was a headache to read lol. there's a lot of redundancy that makes it hard to even figure out where your problems are happening.
Here's something else that Winston didn't mention: 
your text output in A.panel doesn't appear to be updating when you change input$A after you mess with the "Select" tab
because of the input$select statement you have at the beginning of output$A.panel. You should remove that.
Message has been deleted

Christoph Knapp

unread,
Apr 8, 2015, 6:50:08 PM4/8/15
to shiny-...@googlegroups.com
Placing selected.choice in a reactive expression fixed the issue. I'm still wondering why I got this javascript error though. I saw it in the console in firefox and chromium.

Christoph

Christoph
Reply all
Reply to author
Forward
0 new messages