Hello! I'm working on a custom input where I would like the user to press a button and have additional textInput elements appear. For reasons that allude me, each time the button is pressed, the number of new inputs doubles. Following this article on dynamic UIs, I call both Shiny.unbindAll() before inserting a new element and Shiny.bindAll() afterwards. Interestingly, when I remove those calls, pressing the button correctly inserts only one textInput. Of course, their values are not accessible by Shiny, though.
I'm relatively new to custom input bindings, so it's probable I don't understand something correctly or have the unbind and bind functions in the wrong place. Any advice on how I can achieve my goal, though, would be greatly appreciated!
I have run into something similar a while ago. I found out there's also an unbindAll and bindaAll that accept an element as parameter and it solved the issue.
In your binding this looks like
Oh wow, thanks @ginberg! That worked perfectly. Do you know why that parameter is necessary? That is, what is happening behind the scenes when passing el vs. not?
Trying hard to untangle this but will need some help. It looks like unbindall is a wrapper for unbindinputs and the first argument is the scope for what should be unbound/bound (which is el)....
...still totally at a loss as to why adding or removing the shiny-input-binding would effect how many html elements are returned as in your example though