hidden inputs not working?

1,941 views
Skip to first unread message

Aaron Mackey

unread,
Jan 9, 2013, 2:26:41 PM1/9/13
to shiny-...@googlegroups.com
Using an HTML UI, I've switched over a correctly-functioning Shiny webapp from a static multi-select box to a hidden input that gets populated via other JavaScript events.  Yet submitting the form now does not seem to trigger the reactive function that references those hidden inputs.  Pointers?

Thanks,
-Aaron

Joe Cheng

unread,
Jan 9, 2013, 3:04:27 PM1/9/13
to shiny-...@googlegroups.com
I think you may need to create and register an input binding. Please read this carefully:

If that doesn't make sense to you, maybe you can provide some more details about how your app is constructed, and we'll see what we can do to help.


--
 
 

Aaron Mackey

unread,
Jan 9, 2013, 3:14:14 PM1/9/13
to shiny-...@googlegroups.com
From your answer, can I assume then that while you automatically bind to select elements and other input elements, that you do not have an existing input binding to hidden input elements?

Thanks,
-Aaron

--
Aaron J. Mackey, PhD
Assistant Professor
Center for Public Health Genomics
University of Virginia
ama...@virginia.edu
http://www.cphg.virginia.edu/mackey


--
 
 

Joe Cheng

unread,
Jan 9, 2013, 3:17:38 PM1/9/13
to shiny-...@googlegroups.com
That's correct. It would certainly be reasonable to have type="hidden" be automatically bound as well, except that there's no natural "value changed" event for them (that I know of).

You know, it might actually work to just have an input type="text" that happens to be hidden (e.g. style="display:none"). If a change event doesn't fire when you programmatically set the value, you can fire the event yourself using $(el).trigger('change'). Do this as soon as you set the value, there's no need to wait until submit is pressed.


--
 
 

Aaron Mackey

unread,
Jan 9, 2013, 5:20:27 PM1/9/13
to shiny-discuss
In my case, I do want to have things wait until submit is pressed; but it seems that with a submit button on the page, that is what I get for free.  With the display:none textbox, I still need to trigger the change event regardless of the submit button, because otherwise Shiny doesn't think anything happened (and thus won't submit the form when I click the button).

Thanks!

-Aaron


--
 
 

Joe Cheng

unread,
Jan 9, 2013, 7:02:27 PM1/9/13
to shiny-...@googlegroups.com
That's correct. You do need to manually trigger the change event on the hidden textbox, whether a submit button is around or not. But this is still easier than using <input type="hidden">, because for that you need to manually trigger the change event AND write an InputBinding for type="hidden" inputs. In the case of textboxes, the InputBinding already exists and is listening for change events and will do the right thing from there.


--
 
 

Indra Kshattry

unread,
Feb 26, 2014, 2:55:25 PM2/26/14
to shiny-...@googlegroups.com

Indra Kshattry

unread,
Feb 26, 2014, 2:58:39 PM2/26/14
to shiny-...@googlegroups.com
Hello Joe,
I have the same problem, I want hidden but not trigger change. Is there any way that I can accomplish this task in R shiny web apps.

Thank you

Indra


On Wednesday, 9 January 2013 14:17:38 UTC-6, Joe Cheng [RStudio] wrote:
Reply all
Reply to author
Forward
0 new messages