How to clean the 'input' list from values of widgets that no longer exist

25 views
Skip to first unread message

Vincent Laugier

unread,
Dec 4, 2016, 1:32:33 AM12/4/16
to Shiny - Web Framework for R

Hello,

My Shiny application allows the user to create/delete inputs dynamically with some javascript functions.


I then loop over these inputs to get the values (eg. val1 <- input[["input_for_val1"]]).

My problem is that values from deleted inputs remain in the 'input' list.

I have put in attachment a small project to reproduce the problem.

I have tried removing the html widgets using removeUI or javascript (plus unbindAll/bindAll) but it does not help, I guess because once the value is in the 'input' list, it stays there until something on the UI updates it.

I also tried to edit the 'input' list itself (on the server side) but I get an error because it is readonly.

Any idea on how to clean the 'input' list from deleted shiny input widgets?

Best

Vincent

dynamic_widgets.zip

Vincent Laugier

unread,
Dec 12, 2016, 2:32:10 AM12/12/16
to Shiny - Web Framework for R
Hello,

The documentation on htmlwidgets has improved since the last time I checked. These is especially a very usefull post from deanattali.


My workaround is to use a custom widget using htmlwidgets. The widget manages the creation/deletion of input fields and send the inputs as one json message to the server side. For Shiny, this means that there is only one input  so there's no more problem.

Vincent
Reply all
Reply to author
Forward
0 new messages