I've been trying to find a solution how to add and remove input fields with a button in shiny. I don't have a source code since I haven't made that much progress, but this jQuery example (http://www.mkyong.com/jquery/how-to-add-remove-textbox-dynamically-with-jquery/) gives a good idea on what I'm trying to accomplish. Is this possible in shiny or should I use shinyjs to do this? Thank you in advance!
相关问题
- Update two sets of radiobuttons - shiny
- Mathjax not rendering TEX formulas dynamically fro
- Jasper: error opening input stream from url
- How can I prevent my Shiny App from disconnecting
- How to change the width and height of verbatimText
相关文章
- 放在input的text下文本一直出现一个/(即使还没输入任何值)是什么情况
- Angular Material Stepper causes mat-formfield to v
- Saving state of Shiny app to be restored later
- Show a different value from an input that what wil
- Is there a way to hide the new HTML5 spinbox contr
- Shiny - All sub-lists in “choices” must be named?
- Programmatically interrupting raw_input
- Bootstrap input field inside tooltip popover remov
EDIT: I read the jQuery example a bit more, and added a code snippet doing what I think you were looking for.
I don't know jQuery, so I couldn't make much out of the example link. I took a guess on what you wanted, but I think the key idea is the use of
renderUI
anduiOutput
even if my suggestion here misses the point.To toggle a ui element:
If you specifically don't want to use
shinyjs
, you could do something like this:To add and remove elements:
After reading a bit of the jQuery example, I think this is similar to what you were looking for:
The problem with this approach is that each time you press the add or remove button, all of the input boxes get re-rendered. This means that any input you might have had on them disappears.
I think you could get around that by also saving the current input values of the input boxes into a
reactiveValues
object, and setting the values from the object as the starting values of the re-rendered input boxes by using thevalue
option intextInput
. I'll leave the implementation of that for now, though.